<template>
    <div id="content" 
    v-loading="isloading"
    element-loading-text="数据保存中...."
    element-loading-spinner="el-icon-loading"
    element-loading-background="rgba(0, 0, 0, 0.8)"
    >
        <!-- 内容 -->
        <el-row :gutter="10" class="chart_top">
            <!-- Sept1 -->
            <el-col :span="14">
                <el-card shadow="always" :style="{width:'100%',height:autoHeight+'px'}">
                <div style="position: relative;">
                    <!-- <img :src="bgImg" class="bgImg" /> -->
                    <!-- <div id="newPulpLinks"></div> -->
                    <el-table id="planTable" :data="table.data.planTableData" @row-click="planTableRowClick" :height="windowHeight" tooltip-effect  highlight-current-row border stripe>
                        <el-table-column property="drawNo" label="图号" min-width="120" align="center"></el-table-column>
                        <el-table-column property="productNo" label="生产令号" min-width="100" align="center"></el-table-column>
                        <el-table-column property="priority" label="优先级" min-width="60" align="center"></el-table-column>
                        <el-table-column property="planAttribute" label="计划属性" min-width="60" align="center"></el-table-column>
                        <el-table-column property="nums" label="生产数量" min-width="60" align="center" sortable></el-table-column>
                        <el-table-column property="insertOrder" label="插单件" min-width="40" align="center">
                            <template slot-scope="scope">
                                <span v-if="scope.row.insertOrder ===0" ></span>
                                <span v-else class="el-icon-circle-check cl-success fn-size18"></span>
                            </template>
                        </el-table-column>
                        <el-table-column property="planCompleteDate" label="客户需求完成日期" min-width="90" align="center" sortable>
                            <template slot-scope="scope">
                                <div v-html="timestampToTime(scope.row.planCompleteDate,'yy-mm-dds')"></div>
                            </template>
                        </el-table-column>
                        <!-- <el-table-column property="startTime" label="开始时间" min-width="100" align="center"> -->
                            <!-- <template slot-scope="scope">
                                <div v-html="timestampToTime(scope.row.startTime,'yy-mm-dd')"></div>
                            </template> -->
                        <!-- </el-table-column> -->
                        <el-table-column property="A" label="A" min-width="60" align="center">
                            <template slot-scope="scope">
                                {{reckonAToG(scope.row,'A')}}
                            </template>
                        </el-table-column>
                        <el-table-column property="B" label="B" min-width="60" align="center">
                            <template slot-scope="scope">
                                {{reckonAToG(scope.row,'B')}}
                            </template>

                        </el-table-column>
                        <el-table-column property="C" label="C" min-width="60" align="center">
                            <template slot-scope="scope">
                                {{reckonAToG(scope.row,'C')}}
                            </template>

                        </el-table-column>
                        <el-table-column property="D" label="D" min-width="60" align="center">
                            <template slot-scope="scope">
                                {{reckonAToG(scope.row,'D')}}
                            </template>

                        </el-table-column>
                        <el-table-column property="E" label="E" min-width="60" align="center">
                            <template slot-scope="scope">
                                {{reckonAToG(scope.row,'E')}}
                            </template>

                        </el-table-column>
                        <el-table-column property="F" label="F" min-width="60" align="center">
                            <template slot-scope="scope">
                                {{reckonAToG(scope.row,'F')}}
                            </template>

                        </el-table-column>
                        <el-table-column property="G" label="G" min-width="60" align="center">
                            <template slot-scope="scope">
                                {{reckonAToG(scope.row,'G')}}
                            </template>

                        </el-table-column>
                    </el-table>
                     <!-- 分页 -->
                     <!-- <el-pagination background @size-change="planSizeChange" @current-change="planCurrentChange" :current-page="table.pagination.currentPage" :page-sizes="[10, 15,20, 25,30,50, 100]" :page-size="table.pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="table.pagination.total"></el-pagination>     -->
                </div>
                </el-card>
            </el-col>
            <!-- Sept2 -->
            <el-col :span="10" style="margin-top: 0px;">              
                <el-card shadow="always" :style="{width:'100%',height:autoHeight+'px'}">
                <div style="position: relative;">
                    <!-- <img :src="bgImg" class="bgImg" /> -->
                    <!-- <div id="allPulpLinks"></div> -->
                    <el-table id="septTable" :data="table.data.septTableData" v-popover:showCutter @row-click="septTableRowClick"  :height="windowHeight" highlight-current-row border  stripe>
                        <el-table-column property="processFaceName" label="加工面" min-width="55" align="center"></el-table-column>
                        <el-table-column property="fristTotalTime" label="首加工总时间" min-width="80" align="center">
                            <template slot-scope="scope">
                                {{reckonTime(scope.row)}}
                            </template>
                        </el-table-column>
                        <el-table-column property="fristInstall" label="首次装夹对刀时间" min-width="80" align="center"></el-table-column>
                        <el-table-column property="install" label="次装夹对刀时间" min-width="40" align="center"></el-table-column>
                        <el-table-column property="runTime" label="程序运行时间" min-width="40" align="center"></el-table-column>
                        <el-table-column property="fristCheck" label="首检时间" min-width="40" align="center"></el-table-column>
                        <el-table-column property="macId" label="加工设备编号" min-width="60" align="center">
                                <template slot-scope="scope">

                                    <el-select
                                    v-model="scope.row.macId"
                                    @change="dealSelectEventForChange(scope.row)"  
                                    :disabled="scope.row.schedulinged==1"                              
                                    >
                                        <el-option style="z-index:9999"
                                            v-for="item in machineArrayData"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id">
                                            </el-option>
                                    </el-select>

                                </template>
                        </el-table-column>
                        <!-- <el-table-column property="startTime" label="计划开始时间" min-width="100" align="center"></el-table-column> -->
                        <!-- <el-table-column property="finishUseDate" label="计划完成用时" min-width="90" align="center">
                            <template slot-scope="scope">
                                {{complie(scope.row)}}
                            </template>
                        </el-table-column> -->
                        <el-table-column property="finishDate" label="计划完成时间" min-width="70" align="center">
                            <template slot-scope="scope">
                                <div v-if="scope.row.finishDate!=null" :class="scope.row.className" v-html="timestampToTime(scope.row.finishDate,'mm-dd-hh-MM')"></div>
                            </template>
                        </el-table-column>
                    </el-table>    
                </div>   
                <el-popover
                            ref="showCutter"
                            placement="right"
                            width="550"
                            trigger="hover">
                            <el-table :data="table.data.cutterTableData"  :span-method="arraySpanMethod">
                                <el-table-column width="90" property="name" label="刀号"></el-table-column>
                                <el-table-column width="100" property="diameter" label="直径"></el-table-column>
                                <el-table-column width="90" property="depth" label="深度"></el-table-column>
                                <el-table-column width="90" property="blade" label="刃长"></el-table-column>
                                <el-table-column width="90" property="mo" label="磨"></el-table-column>
                                <el-table-column width="90" property="useTime" label="用时"></el-table-column>
                            </el-table>
                </el-popover>
                <el-popover
                            ref="showScheduling"
                            placement="bottom"
                            width="200"
                            trigger="hover">
                            <el-form>
                            <el-form-item>
                                早班：00:00-08:00
                            </el-form-item>
                            <el-form-item>
                                白班：08:00-16:00
                            </el-form-item>
                            <el-form-item>
                                夜班：16:00-24:00
                            </el-form-item>
                            </el-form>
                </el-popover>
                </el-card>
            </el-col>
            <!-- Sept3 （甘特图）-->
            <el-col :span="24" style="margin-top: 15px;">
                <el-card shadow="always" style="width:100%;height:500px;">
                <div style="position: relative;width:100%;height:500px;">
                    <!-- <img :src="bgImg" class="bgImg" /> -->
                        <el-row class="data_box" style="position:absolute;top:-7px;right:10px;z-index:1999">   
                            <el-popover
                            ref="initConfig"
                            placement="right"
                            width="650"
                            trigger="click">
                            <h1 style="color: #FFFFFF;background-color: #3ac1c4;margin:15px 0 15px 0;padding:5px 0px 5px 15px; border-radius:3px;">设备开始时间配置</h1>
                            <el-form :inline="true" :model="search" label-width="90px"  class="search-panle">  
                              <span v-for="(item,i) in machineArrayData">                                 
                                <el-form-item :label="item.id+'号设备:'" style="margin:5px 10px 5px 10px;">
                                   <el-date-picker
                                        v-model="table.machine['mac'+item.id].initTime"
                                        type="datetime"
                                        placeholder="选择日期"
                                        style="width:185px;"
                                        >
                                    </el-date-picker>
                                </el-form-item>
                                <span v-if="(item.id%2)===0"><br/></span>
                              </span>                         
                                <el-form-item label="生产间隔:">
                                <el-input
                                    placeholder="请输入配置,默认15分钟"
                                    v-model="sperator" minlength="100" size="mini"   style="width:100px;margin-top:10px;margin-left:20px;">
                                </el-input>/分钟
                                </el-form-item>
                            </el-form>
                            </el-popover>
                            <el-popover
                            ref="detaill"
                            placement="right"
                            width="550"
                            trigger="click"
                            >
                            <div style="border:1px solid gray;width:50%;height:40%;">
                            <h1>功能开发中......</h1>
                            </div>
                            </el-popover>
                            <el-popover
                             ref="search"
                             placement="right"
                             width="750"
                             trigger="manual"
                             v-model="searchPopoverShow"
                            >
                                <!-- <el-form :inline="true" :model="search" label-width="90px"  class="search-panle"> 
                                    <el-form-item label="操作人员:">
                                        <el-input></el-input>
                                    </el-form-item>
                                    <el-form-item label="实操人员:">
                                        <el-input></el-input>
                                    </el-form-item>
                                    <br/>
                                    <el-button type="primary" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" >查询</el-button>

                                </el-form> -->
                               
                                <h1 style="color: #FFFFFF;background-color: #3ac1c4;margin-bottom:15px;padding:5px 0px 5px 15px; border-radius:3px;">操作人</h1>
                                <div style="width:90%;height:40%;border:1px solid gray; margin:0 auto; padding:5px 5px 5px 5px;">
                                    <el-checkbox-group v-model="operatorList">
                                        <span v-for="(item,i) in operatorData">
                                        <el-checkbox :label="item.id">{{item.name}}</el-checkbox>
                                        &nbsp;
                                        </span>
                                    </el-checkbox-group>

                                </div>
                                <h1 style="color: #FFFFFF;background-color: #3ac1c4;margin-bottom:15px; margin-top:15px; padding:5px 0px 5px 15px; border-radius:3px;">设备</h1>
                                <div style="width:90%;height:40%;border:1px solid gray; margin:0 auto;  padding:5px 5px 5px 5px;">
                                    <el-checkbox-group v-model="machineList">
                                        <span v-for="(item,i) in machineArrayData">
                                        <el-checkbox :label="item.id">{{item.name}}</el-checkbox>
                                        &nbsp;
                                        </span>
                                    </el-checkbox-group>
                                </div>
                                <h1 style="color: #FFFFFF;background-color: #3ac1c4;margin-bottom:15px;  margin-top:15px; padding:5px 0px 5px 15px; border-radius:3px;">负荷</h1>
                                <div style="width:100%;height:15%;border:1px solid gray;  margin:0 auto; padding:5px 5px 5px 5px;overflow:hidden;">
                                    <el-table  :data="table.data.searchWorkerLoadData" height="250" tooltip-effect  highlight-current-row border stripe>
                                  
                                        <el-table-column label="设备" prop="macName">
                                        </el-table-column>
                                        <el-table-column label="班次" prop="classes">
                                        </el-table-column>
                                        <el-table-column label="首次装夹负荷" prop="firstClampingWorkLoadRemark">
                                        </el-table-column>
                                        <el-table-column label="首次装夹次数" prop="firstClampingCount">
                                        </el-table-column>
                                        <el-table-column label="首次装夹时长" prop="firstClampingSumRemark">
                                        </el-table-column>
                                        <el-table-column label="次装夹负荷" prop="clampingWorkLoadRemark">
                                        </el-table-column>
                                        <el-table-column label="次装夹次数" prop="clampingCount">
                                        </el-table-column>
                                        <el-table-column label="次装夹时长" prop="clampingSumRemark">
                                        </el-table-column>
                                    </el-table>                             
                                    <el-table  :data="table.data.searchWorkerOperatorLoadData"     height="250" tooltip-effect  highlight-current-row border stripe>
                                        <el-table-column label="人员" prop="workerName">
                                        </el-table-column>
                                        <el-table-column label="班次" prop="classes">
                                        </el-table-column>
                                        <el-table-column label="首次装夹负荷" prop="firstClampingWorkLoadRemark">
                                        </el-table-column>
                                        <el-table-column label="首次装夹次数" prop="firstClampingCount">
                                        </el-table-column>
                                        <el-table-column label="首次装夹时长" prop="firstClampingSumRemark">
                                        </el-table-column>
                                        <el-table-column label="次装夹负荷" prop="clampingWorkLoadRemark">
                                        </el-table-column>
                                        <el-table-column label="次装夹次数" prop="clampingCount">
                                        </el-table-column>
                                        <el-table-column label="次装夹时长" prop="clampingSumRemark">
                                        </el-table-column>
                                     
                                    </el-table>                             
                                </div>
                                <el-button type="primary" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="searchPopoverHander" >查询</el-button>
                                <el-button type="primary" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="clearSearchPopoverHander" >清空</el-button>
                                <el-button type="danger" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="closeSearchPopover" >关闭</el-button>
                            </el-popover>
                            <el-popover
                            ref="insertOrder"
                            placement="right"
                            width="550"
                            trigger="manual"
                            v-model="insertOrder.isShow"
                            >
                            <h1 style="color: #FFFFFF;background-color: #3ac1c4;margin-bottom:15px;padding:5px 0px 5px 15px; border-radius:3px;">待插单</h1>
                            <el-form :inline="true" :model="search" label-width="160px"  class="search-panle"> 
                                <!-- <el-form-item label="任务ID:">
                                    {{insertOrder.id}}
                                </el-form-item>
                                <el-form-item label="工艺ID:">
                                    {{insertOrder.tid}}
                                </el-form-item> -->
                                <div style="width:90%;height:100%;border:1px solid gray; margin:0 auto; padding:5px 5px 5px 5px;">
                                    <el-form-item label="图纸号:">
                                        {{insertOrder.drawNo}}
                                    </el-form-item>
                                    <br/>
                                    <el-form-item label="生产令号:">
                                        {{insertOrder.productNo}}
                                    </el-form-item>
                                    <el-form-item label="客户需求时间:">
                                        {{insertOrder.planCompleteDate}}
                                    </el-form-item>
                                    <!-- <el-form-item label="开始时间:">
                                        {{insertOrder.startTime}}
                                    </el-form-item>
                                    <el-form-item label="结束时间:">
                                        {{insertOrder.endTime}}
                                    </el-form-item> -->
                                    <br/>
                                    <el-form-item label="加工面:">
                                        {{insertOrder.processFace}}
                                    </el-form-item>
                                    <el-form-item label="加工数量:">
                                        {{insertOrder.nums}}
                                    </el-form-item>
                                    <el-form-item label="设备编号:">
                                        {{insertOrder.macId}}
                                    </el-form-item>
                                </div>
                                <h1 style="color: #FFFFFF;background-color: #3ac1c4;margin:15px 0 15px 0;padding:5px 0px 5px 15px; border-radius:3px;">插单设置</h1>
                                <div style="width:90%;height:100%;border:1px solid gray; margin:0 auto; padding:15px 5px 5px 5px;">
                                    <el-form-item label="插单开始时间:">
                                        <el-date-picker
                                        v-model="insertOrder.showTime"
                                        type="datetime"
                                        placeholder="选择日期"
                                        style="width:200px;margin-top: 0px;"
                                        @change="queryGanttByMacNoTime"
                                        >
                                    </el-date-picker>
                                    </el-form-item>
                                    <el-form-item label="设备号:">
                                        <el-select
                                        v-model="insertOrder.macId" style="margin-left: 10px;" 
                                        @change="queryGanttByMacNoTime"
                                        >
                                            <el-option style="z-index:9999;"
                                                v-for="item in machineArrayData"
                                                :key="item.id"
                                                :label="item.name"
                                                :value="item.id">
                                                </el-option>
                                        </el-select>
                                    </el-form-item>
                                    <br/>
                                    <!-- <el-form-item label="最近排程完成时间:">
                                        &nbsp;&nbsp;{{insertOrder.nearTime}}
                                    </el-form-item> -->
                                    <el-form-item label="所选时间任务起止时间:">
                                        &nbsp;&nbsp;<span v-html="insertOrder.startMacTime"></span> <span v-html="insertOrder.endMacTime"></span>
                                    </el-form-item>
                                    <br/>
                                </div>
                            </el-form> 
                            <el-button type="primary" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="submitButtonEvent">确定</el-button>
                            <el-button type="danger" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="closeInsertOrderPopover">关闭</el-button>
                        
                            </el-popover>
                            <el-button  type="primary"  size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" v-popover:initConfig>配置</el-button>
                            <!-- <el-button type="primary" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="seeIsCtrl">查看ctrl</el-button> -->
                            <el-button type="primary" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="savePlan">保存</el-button>
                            <el-button type="primary" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="restGanttMap">重置</el-button>
                            <span style="font-weight:bold;font-size:16px;">&nbsp; 实时&nbsp;:&nbsp;</span>
                            <el-switch
                                v-model="sychVal"
                                active-color="#13ce66"
                                inactive-color="#ff4949"
                                active-text="开"
                                inactive-text="关"
                                style="margin-top:-2px;"
                                >
                             </el-switch>
                            <!-- <el-button type="danger" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="initWebSocket">websocket</el-button>  
                            <el-button type="danger" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="sendWebSocket">发送消息</el-button>   -->
                            <el-button type="danger" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="inseartOrderEvent" v-popover:insertOrder>插单</el-button>  
                            <el-button  type="danger"  size="small" style="margin-bottom:0px; float:left;margin:10px 15px 10px 5px;"  onclick="openOperator()">操作人</el-button>
                            <el-button  type="primary"  size="small" style="margin-bottom:0px; float:left;margin:10px 15px 10px 5px;" onclick="openResponse()" >实操人</el-button>
                            <el-button  type="primary"  size="small" style="margin-bottom:0px; float:left;margin:10px 5px 10px 5px;" @click="searchPopoverEvent" v-popover:search >查询</el-button>
                            <el-button  type="primary"  size="small" style="margin-bottom:0px; float:left;margin:10px 15px 10px 5px;" @click="up">上一天</el-button>
                            <el-date-picker
                                v-model="search.showTime"
                                type="date"
                                placeholder="选择日期"
                                style="width:130px;"
                                @change="showGanttMapByDate"
                                >
                            </el-date-picker>
                            <el-button  type="primary"  size="small" style="margin-bottom:0px; float:left;margin:10px 5px 10px 5px;" @click="next" >下一天</el-button>
                        </el-row>                   
                    <div id="gantt_p" style="width:100%;height:500px;overflow:scroll;">
                        <div id="gantt" style="width:100%;height:600px;">

                        </div>
                    </div>                  
                    <el-dialog title="操作人选择" width="20%"  :visible.sync="dialogOperatorVisible">
                        <el-form>
                            <el-form-item label="班次:">
                                <el-select
                                    v-model="operator.shift" style="margin-left: 10px;" 
                                    @change="operatorShiftEvent"
                                    >
                                        <el-option
                                            v-for="item in operator.operatorShift"
                                            :key="item.value"
                                            :label="item.name"
                                            :value="item.value">
                                        </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="人员:">
                                <el-select
                                    v-model="operator.operator" style="margin-left: 10px;" 
                                    >
                                        <el-option
                                            v-for="item in operator.operatorData"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id">
                                        </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item>
                            <el-button  type="primary"  size="small" style="float:right" @click="saveOperator(1)">确定</el-button>
                            </el-form-item>
                        </el-form>
                    </el-dialog>
                    <el-dialog title="实操人员" width="30%" :visible.sync="dialogResponseVisible">
                        <el-form>
                            <el-form-item label="班次:">
                                <el-select
                                    v-model="operator.shift" style="margin-left: 10px;" 
                                    @change="operatorShiftEvent"
                                    >
                                        <el-option
                                            v-for="item in operator.operatorShift"
                                            :key="item.value"
                                            :label="item.name"
                                            :value="item.value">
                                        </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="人员:">
                                <el-select
                                    v-model="operator.operator" style="margin-left: 10px;" 
                                    >
                                        <el-option
                                            v-for="item in operator.operatorData"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id">
                                        </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="备注:">
                                <el-input placeholder="请输入备注信息" v-model="operator.remark">
                                </el-input>
                            </el-form-item>
                            <el-form-item>
                            <el-button  type="primary"  size="small" style="float:right" @click="saveOperator(2)">确定</el-button>
                            </el-form-item>
                        </el-form>
                    </el-dialog>
                    <el-dialog  width="30%" :visible.sync="dialogDetailVisible">
                        <h1 style="color: #FFFFFF;background-color: #3ac1c4;margin-bottom:15px;width:93%;  margin-top:-45px; padding:5px 0px 5px 15px; border-radius:3px;">详情</h1>
                        <el-form :inline="true" :model="search" label-width="160px"  class="search-panle"> 
                        <div style="width:90%;height:100%;border:1px solid gray; margin:0 auto; padding:5px 5px 5px 5px;">
                            <el-form-item label="图号:">{{dialog.dialogDetail.drawNo}}</el-form-item>
                            <el-form-item label="生产令号:">{{dialog.dialogDetail.productNo}}</el-form-item>
                            <el-form-item label="优先级:">{{dialog.dialogDetail.priority}}</el-form-item>
                            <el-form-item label="计划属性:">{{dialog.dialogDetail.planAttribute}}</el-form-item>
                            <el-form-item label="生产数量:">{{dialog.dialogDetail.nums}}</el-form-item>
                            <el-form-item label="插单件:">{{dialog.dialogDetail.insertOrder}}</el-form-item>
                            <el-form-item label="客户需求完成日期:">{{dialog.dialogDetail.planCompleteDate}}</el-form-item>
                            <br/>
                            <el-form-item label="A:">{{dialog.dialogDetail.A}}</el-form-item>
                            <el-form-item label="B:">{{dialog.dialogDetail.B}}</el-form-item>
                            <el-form-item label="C:">{{dialog.dialogDetail.C}}</el-form-item>
                            <el-form-item label="D:">{{dialog.dialogDetail.D}}</el-form-item>
                            <el-form-item label="E:">{{dialog.dialogDetail.E}}</el-form-item>
                            <el-form-item label="F:">{{dialog.dialogDetail.F}}</el-form-item>
                            <el-form-item label="G:">{{dialog.dialogDetail.G}}</el-form-item>
                        </div>
                        </el-form>
                    </el-dialog>
                </div>
                </el-card>
            </el-col>
        </el-row>
        <!-- 放大弹出层 -->
        <!-- <el-dialog :visible.sync="ganttMapDialog" :fullscreen='true' :show-close='false'>
            <div id='ganttMapBigId' class="ganttMapDialog"></div>
        </el-dialog> -->
    </div>
</template>
<script>
let timer = null;
import echarts from 'echarts';
import planApi from 'plugins/axios/planApi.js';
// 图片引入
import bgImg from "images/yynlfxBackground.png";
import big from "images/cover_big.png";
import small from "images/cover_small.png";
import setTing from "images/cover_setTing.png";
import { log } from 'util';
export default {
    data(){
        return{
            operatorList:[],
            machineList:[],
            operatorData:[],
            machineArrayData:[],
            searchPopoverShow:false,
            isfristBindEvent:true,
            isInsertOrderBottom:false,
            selectSperatorArray:new Array(),
            curInt:null,
            current:null,
            option:{},
            isCtrl:false,
            dialogDetailVisible:false,
            dialogOperatorVisible:false,
            dialogResponseVisible:false,
            sychVal:true,
            timer:null,
            isPlanTimeOut:false,
            websocket:null,
            isPlan:false,
            isloading:false,
            sperator:15,
            initMacTime:{
                mac1:new Date(),
                mac2:new Date(),
                mac3:new Date(),
                mac4:new Date(),
                mac5:new Date(),
                mac6:new Date(),
                mac7:new Date(),
                mac8:new Date(),
                mac9:new Date(),
                mac10:new Date(),
                mac11:new Date(),
                mac12:new Date(),
                mac13:new Date(),
                mac14:new Date(),
                mac15:new Date(),
                mac16:new Date(),
                mac17:new Date(),
                mac18:new Date(),
                mac19:new Date(),
                mac20:new Date(),
                mac21:new Date(),
                mac22:new Date(),
                mac23:new Date()
            },
            search:{
                showTime:null,
                date:this.timestampToTime(new Date(),'yyyy-mm-dd'),
            },
            initShowTime:null,
            currentShift:null,
            shift:{
                s1:'早班(0-8)',
                s2:'白班(8-16)',
                s3:'夜班(16-24)',
            },
            trigger:{
                isFristInstall:true,
                isRunTime:true,
                isInstall:true,
                isFristCheck:true,
            },
            morningShift:'早班(0:00-8:00)',
            dayShift:'白班(8:00-16:00)',
            nightShift:'夜班(16:00-24:00)',
            scheduling:'null',
            showTime:'/',
            operator:{
                operator1:[],       //早班
                operator2:[],       //白班
                operator3:[],       //夜班
                operatorShift:[
                    {name:'早班',value:1},
                    {name:'白班',value:2},
                    {name:'夜班',value:3}
                ],   //操作班次
                operatorData:[],    //对应班次人员信息
                shift:1,            //所选班次 默认早班被选中
                operator:'',        //被选中的人
                remark:'',          //备注
                planResultIds:[],   //计划工艺甘特图后台数据id（批量）
                planResultId:'',    //计划工艺结果ID(单)
            },
            grid:{
                XstartTime:new Date(),
                XendTime:new Date(),
                YAxisData:[],
            },
            ganttChart:null,
            save:{
                fristInstall:[],
                install:[],
                runTime:[],
                fristCheck:[], 
            },
            original:{
                A:[
                    {name:'1',value:['1',
                    new Date('2019/10/28 10:22:01'),
                    new Date('2019/10/28 14:22:01')
                    ]}
                ],
                B:[],
                C:[],
                D:[],
                E:[],
                F:[],
                G:[],
                fristInstall:[],
                install:[],
                runTime:[],
                fristCheck:[], 
                macEndTime:[],   
            },
            gantt:{
                series:[],
                A:[],
                B:[],
                C:[],
                D:[],
                E:[],
                F:[],
                G:[],
                fristInstall:[],
                install:[],
                runTime:[],
                fristCheck:[],  
                macEndTime:[],  
            },
            valDate:null,
            insertOrder:{
                isCreate:false,
                isShow:false,
                type:1,                //type =1 有加工面，需要计算加工时间 =2 没有加工面，不需要计算加工面，就排程人员手动选择排程
                nearTime:this.timestampToTime(new Date(), 'yyyy-mm-dd hh:mm:ss'), //设备最近完成时间
                showTime:new Date(),    //需要插入时间
                tid:'1',                //详情id
                id:'2',                 //任务id
                drawNo:'3',             //图纸号
                productNo:'4',          //生成令号
                nums:'5',               //加工数量
                planCompleteDate:null,  //需求完成时间
                startTime:'6',          //开始时间
                endTime:'7',            //结束时间
                macId:'8',              //设备编号
                processFace:'1',        //加工面
                startMacTime:'',        //当前所选设备所选时间在已存储的排程时间段开始时间
                endMacTime:'',          //当前所选设备所选时间在已存储的排程时间段结束时间
                fristInstall:'',        //首次装夹时间
                install:'',             //装夹时间
                fristCheck:'',          //首检时间 
                runTime:'',             //运行时间
                totalId:'',             //总计划id

            },
            windowHeight: document.documentElement.clientHeight /2- 50,
            table:{
                currentPlanFousRow:{
                    nums:'',             //任务要求生产数量
                    planCompleteDate:'', //客户要求完成时间
                    drawNo:'',           //图纸号
                    productNo:'',        //生产令号
                    id:'',               //任务id
                    tid:'',              //详情id
                    totalId:'',          //总计划id
                },
                search:{
                    planTable:{
                        id:'',
                        drawNo:'',
                        productNo:''
                    },
                    septTable:{
                        select:{
                            macId:'',
                        }
                    }
                },
                data:{
                    planTableData:[],
                    septTableData:[],
                    macSelectData:[],
                    popoverTableData:[],
                    cutterTableData:[],
                    searchTableData:[],
                    searchWorkerLoadData:[],
                    searchWorkerOperatorLoadData:[]
                },
                initTime:this.getDateByType(new Date(),'end'),
                machine:{
                    mac1:{initTime:new Date()},
                    mac2:{initTime:new Date()},
                    mac3:{initTime:new Date()},
                    mac4:{initTime:new Date()},
                    mac5:{initTime:new Date()},
                    mac6:{initTime:new Date()},
                    mac7:{initTime:new Date()},
                    mac8:{initTime:new Date()},
                    mac9:{initTime:new Date()},
                    mac10:{initTime:new Date()},
                    mac11:{initTime:new Date()},
                    mac12:{initTime:new Date()},
                    mac13:{initTime:new Date()},
                    mac14:{initTime:new Date()},
                    mac15:{initTime:new Date()},
                    mac16:{initTime:new Date()},
                    mac17:{initTime:new Date()},
                    mac18:{initTime:new Date()},
                    mac19:{initTime:new Date()},
                    mac20:{initTime:new Date()},
                    mac21:{initTime:new Date()},
                    mac22:{initTime:new Date()},
                    mac23:{initTime:new Date()},
                    mac24:{initTime:new Date()},
                    mac25:{initTime:new Date()},
                    mac26:{initTime:new Date()},
                    mac27:{initTime:new Date()},
                    mac28:{initTime:new Date()},
                    mac29:{initTime:new Date()},
                    mac30:{initTime:new Date()},
                    mac31:{initTime:new Date()},
                    mac32:{initTime:new Date()},
                    mac33:{initTime:new Date()},
                    mac34:{initTime:new Date()},
                    mac35:{initTime:new Date()},
                    mac36:{initTime:new Date()},
                    mac37:{initTime:new Date()},
                    mac38:{initTime:new Date()},
                    mac39:{initTime:new Date()},
                    mac40:{initTime:new Date()},
                },
                pagination:{
                    currentPage:1,
                    pageSize:100,
                    total:0
                }  
            },
            dialog:{
                detailSearchCondtion:{
                    tId:'',
                    totalId:'',
                },
                dialogDetail:{
                    drawNo:'',
                    productNo:'',
                    priority:'',
                    planAttribute:'',
                    nums:'',
                    insertOrder:'',
                    planCompleteDate:'',
                    A:'',
                    B:'',
                    C:'',
                    D:'',
                    E:'',
                    F:'',
                    G:'',
                }
            }

        }
    },
    created(){
        let self = this;
        window.self = this;
        self.init();
    },
    watch:{
        'sychVal':function(val){
            let self = this;
            if(val){
                self.openIntervalTime();
            }else{
                self.closeIntervalTime();
            }
        }
    },
    computed:{
        autoHeight(){
            return this.$store.state.clientHeight/2-120;
        }
     },
    methods:{
        //根据totalId，tid获取【查看详情】按钮的信息
        getDetailInfo(){
            let self = this;
            let params={
                currentPage:self.table.pagination.currentPage,
                pageSize:self.table.pagination.pageSize,
                drawNo:self.table.search.drawNo,
                productNo:self.table.search.productNo,
                tid: self.dialog.detailSearchCondtion.tId ,
                totalId: self.dialog.detailSearchCondtion.totalId
            };
            planApi.planTaskList(params).then(res=>{
                self.convertParamsToVal(res.content.records[0]);
            });

        },
        //将查询结果赋值给详情对象
        convertParamsToVal(params){
            let self = this;
            if(params != null && params!=undefined){
                self.dialog.dialogDetail.drawNo = params.drawNo;
                self.dialog.dialogDetail.productNo = params.productNo;
                self.dialog.dialogDetail.priority = params.priority;
                self.dialog.dialogDetail.planAttribute = params.planAttribute;
                self.dialog.dialogDetail.nums = params.nums;
                self.dialog.dialogDetail.insertOrder = params.insertOrder;
                self.dialog.dialogDetail.planCompleteDate = params.planCompleteDate;
                self.dialog.dialogDetail.A = self.reckonAToG(params,'A');
                self.dialog.dialogDetail.B = self.reckonAToG(params,'B');
                self.dialog.dialogDetail.C = self.reckonAToG(params,'C');
                self.dialog.dialogDetail.D = self.reckonAToG(params,'D');
                self.dialog.dialogDetail.E = self.reckonAToG(params,'E');
                self.dialog.dialogDetail.F = self.reckonAToG(params,'F');
                self.dialog.dialogDetail.G = self.reckonAToG(params,'G');
            }
        },
        //清空查询条件，重置
        clearSearchPopoverHander(){
            let self = this;
            self.machineList=[];
            self.operatorList=[];
            self.table.data.searchWorkerLoadData=[];
            self.table.data.searchWorkerOperatorLoadData=[];
        },
        //查询事件
        searchPopoverHander(){
            let self = this;
            let condition={
                date:self.timestampToTime(self.search.date,'yyyy-mm-dd') ,
                mac:self.machineList,
                planPerformer:self.operatorList,
                realPerformer:null,
            }
            // console.log(condition);
            planApi.planTaskSearchGanttList(condition).then(res=>{
                // let content =eval('('+res+')');
                // console.log(res);
                let content = JSON.parse(res.content);
                //1进行查询数据的备份存储
                self.original.fristInstall = content.planResults.fristInstall;
                self.original.install = content.planResults.install;
                self.original.runTime = content.planResults.runTime;
                self.original.fristCheck = content.planResults.fristCheck;
                self.original.macEndTime = content.planResults.macEndTime;
                //2进行甘特图展示数据查看
                self.gantt.fristInstall = content.planResults.fristInstall;
                self.gantt.install = content.planResults.install;
                self.gantt.runTime = content.planResults.runTime;
                self.gantt.fristCheck = content.planResults.fristCheck;
                self.gantt.macEndTime = content.planResults.macEndTime;
                //进行上次保存的数据存档
                self.gantt.fristInstall =  self.gantt.fristInstall.concat(self.save.fristInstall);
                self.gantt.install =  self.gantt.install.concat(self.save.install);
                self.gantt.runTime =  self.gantt.runTime.concat(self.save.runTime);
                self.gantt.fristCheck =  self.gantt.fristCheck.concat(self.save.fristCheck);
                self.isloading = false;
                self.initGanttMap();
                self.setInitMacTime(self.gantt.macEndTime);
                self.selectWorkerLoad(condition);
            });


        },
        //查询负荷
        selectWorkerLoad(params){
            let self = this;
            debugger;
            planApi.planTaskSearchWorkerLoadList(params).then(res=>{
                if(res.content!=null){
                    let macLoadMapData = res.content.macLoadMap;  
                    let workerLoadMap = res.content.workerLoadMap; 
                    //进行参数加工
                    self.setWorkerLoadData(macLoadMapData); 
                    self.setWorkerMacLoadData(workerLoadMap); 
                };
            });
        },
        //进行负荷查询结果集后台返回数据的遍历加工成el-table可装填的数据结构
        setWorkerLoadData(data){
            let self = this;
            if(data!=null){
                for(let attr in data){ 
                    let totalRowObj =  data[attr];
                    let classes01 = totalRowObj.classes01;
                    let classes02 = totalRowObj.classes02;
                    let classes03 = totalRowObj.classes03;
                    let rowData1 = {};
                    let rowData2 = {};
                    let rowData3 = {};
                    rowData1['macName'] = totalRowObj.macName;
                    rowData1['classes'] = "早班";
                    rowData1['firstClampingWorkLoadRemark'] = classes01.firstClampingWorkLoadRemark;
                    rowData1['firstClampingSumRemark'] = classes01.firstClampingSumRemark;
                    rowData1['firstClampingCount'] = classes01.firstClampingCount;
                    rowData1['clampingWorkLoadRemark'] = classes01.clampingWorkLoadRemark;
                    rowData1['clampingCount'] = classes01.clampingCount;
                    rowData1['clampingSumRemark'] = classes01.clampingSumRemark;

                    rowData2['macName'] = totalRowObj.macName;
                    rowData2['classes'] = "白班";
                    rowData2['firstClampingWorkLoadRemark'] = classes02.firstClampingWorkLoadRemark;
                    rowData2['firstClampingSumRemark'] = classes02.firstClampingSumRemark;
                    rowData2['firstClampingCount'] = classes02.firstClampingCount;
                    rowData2['clampingWorkLoadRemark'] = classes02.clampingWorkLoadRemark;
                    rowData2['clampingCount'] = classes02.clampingCount;
                    rowData2['clampingSumRemark'] = classes02.clampingSumRemark;
                    rowData3['macName'] = totalRowObj.macName;
                    rowData3['classes'] = "夜班";
                    rowData3['firstClampingWorkLoadRemark'] = classes03.firstClampingWorkLoadRemark;
                    rowData3['firstClampingSumRemark'] = classes03.firstClampingSumRemark;
                    rowData3['firstClampingCount'] = classes03.firstClampingCount;
                    rowData3['clampingWorkLoadRemark'] = classes03.clampingWorkLoadRemark;
                    rowData3['clampingCount'] = classes03.clampingCount;
                    rowData3['clampingSumRemark'] = classes03.clampingSumRemark;
                   self.table.data.searchWorkerLoadData.push(rowData1);
                   self.table.data.searchWorkerLoadData.push(rowData2);
                   self.table.data.searchWorkerLoadData.push(rowData3);
                }
            }
        },
        setWorkerMacLoadData(data){
            let self = this;
            if(data!=null){
                for(let attr in data){ 
                    let totalRowObj =  data[attr];
                    let classes01 = totalRowObj.classes01;
                    let classes02 = totalRowObj.classes02;
                    let classes03 = totalRowObj.classes03;
                    let rowData1 = {};
                    let rowData2 = {};
                    let rowData3 = {};
                    rowData1['workerName'] = totalRowObj.workerName;
                    rowData1['classes'] = "早班";
                    rowData1['firstClampingWorkLoadRemark'] = classes01.firstClampingWorkLoadRemark;
                    rowData1['firstClampingSumRemark'] = classes01.firstClampingSumRemark;
                    rowData1['firstClampingCount'] = classes01.firstClampingCount;
                    rowData1['clampingWorkLoadRemark'] = classes01.clampingWorkLoadRemark;
                    rowData1['clampingCount'] = classes01.clampingCount;
                    rowData1['clampingSumRemark'] = classes01.clampingSumRemark;

                    rowData2['workerName'] = totalRowObj.workerName;
                    rowData2['classes'] = "白班";
                    rowData2['firstClampingWorkLoadRemark'] = classes02.firstClampingWorkLoadRemark;
                    rowData2['firstClampingSumRemark'] = classes02.firstClampingSumRemark;
                    rowData2['firstClampingCount'] = classes02.firstClampingCount;
                    rowData2['clampingWorkLoadRemark'] = classes02.clampingWorkLoadRemark;
                    rowData2['clampingCount'] = classes02.clampingCount;
                    rowData2['clampingSumRemark'] = classes02.clampingSumRemark;
                    rowData3['workerName'] = totalRowObj.workerName;
                    rowData3['classes'] = "夜班";
                    rowData3['firstClampingWorkLoadRemark'] = classes03.firstClampingWorkLoadRemark;
                    rowData3['firstClampingSumRemark'] = classes03.firstClampingSumRemark;
                    rowData3['firstClampingCount'] = classes03.firstClampingCount;
                    rowData3['clampingWorkLoadRemark'] = classes03.clampingWorkLoadRemark;
                    rowData3['clampingCount'] = classes03.clampingCount;
                    rowData3['clampingSumRemark'] = classes03.clampingSumRemark;
                   self.table.data.searchWorkerOperatorLoadData.push(rowData1);
                   self.table.data.searchWorkerOperatorLoadData.push(rowData2);
                   self.table.data.searchWorkerOperatorLoadData.push(rowData3);
                }
            }
        },
        //查看变量事件
        seeIsCtrl(){
            alert(window.isCtrl);
        },
        //点击甘特图事件监听
        listenerForClikcGanttMap(){
            let self = this;
            if(self.ganttChart!=null){
                self.ganttChart.on("dblclick",function(params){
                    self.ganttChart.clear();
                    //self.ganttChart.off('click')
                    console.log(params.value[12]);
                    self.curInt =  params.value[12];
                    if(self.isContain(params.value[12])){
                        self.removeContain(params.value[12]);
                    }else{
                        self.selectSperatorArray.push(params.value[12]);
                    }
                    self.setGanttChartOption();
                    self.ganttChart.setOption(self.option,false);
                });
                self.ganttChart.on("legendselectchanged", function(params) {
                    let select = params.selected;                 
                        self.trigger.isFristInstall = select.首次装夹;
                        self.trigger.isInstall = select.次装夹;
                        self.trigger.isRunTime = select.程序运行;
                        self.trigger.isFristCheck = select.首检;
                
                        //   self.trigger.isFristInstall,
                        //  次装夹:self.trigger.isInstall,
                        //  程序运行:self.trigger.isRunTime,
                        //  首检:self.trigger.isFristCheck
                    //self.trigger =params.selected;
                });
                window.addEventListener("resize", () => {
                    self.ganttChart.resize();
                });
            }
        },
        //进行组合键盘监听事件定义
        listenerForWindowEvent(){
            let self = this;
            // window.isCtrl = false;
            // window.onkeydown = function(event){
            //     let e = event || window.event || arguments.callee.caller.arguments[0]; 
            //         if(e.ctrlKey){    
            //             window.isCtrl = true;
            //         }
        
            // };
            // window.onkeyup  = function(event){
            //     let e = event || window.event || arguments.callee.caller.arguments[0]; 
            //     console.log(e);
            //         if(e.ctrlKey){    
            //             window.isCtrl = false;
            //         }
            // };
        },
        //保存操作者的数据
        saveOperator(type){
            let self = this;
            let planResultId = null;
            let operator = self.operator.operator;
            let remark = self.operator.remark;
            let params ={};
            let operatorMap = {};
            // if(type==1){
            //     alert(operator);
            // }else{
            //     alert(operator);
            // }
            if(self.selectSperatorArray!=null && self.selectSperatorArray.length!=0){   //批量（用户双击甘特图）
               self.selectSperatorArray.forEach(element => {
                    operatorMap[element]=operator;
                });
            }else{
                operatorMap[self.operator.planResultId]=operator;                       //单个（用户单击甘特图）
            }
            params['remark'] = remark;
            params['operatorMap'] = operatorMap;

            planApi.saveOperatorListData(type,params).then(res=>{
                self.$message({
                        message: '数据保存成功！',
                        type: 'success'
                    });
                //清空上次操作的数组
                self.selectSperatorArray = [];
                //关闭确定dialog
                self.closeAllDialog();
                //重置甘特图
                self.restGanttMap();            //保存成功后刷新甘特图
                self.restfuSpetTable();         //保存成功后刷新加工面展示框
            });
        },
        //关闭所有的dialog弹窗
        closeAllDialog(){
            let self = this;
            self.dialogDetailVisible = false;
            self.dialogOperatorVisible = false;
            self.dialogResponseVisible = false;
        },
        //选操作者 班次change事件联动变更人员处理函数
        operatorShiftEvent(){
            let self  = this;
            switch (self.operator.shift) {
                case 1: self.operator.operatorData = self.operator.operator1; self.operator.operator=self.operator.operatorData[0].id;break;
                case 2: self.operator.operatorData = self.operator.operator2; self.operator.operator=self.operator.operatorData[0].id;break;
                case 3: self.operator.operatorData = self.operator.operator3; self.operator.operator=self.operator.operatorData[0].id;break;  
                default: break;
            }   
        },
        //插单确定按钮事件处理函数
        submitButtonEvent(){
            let self =  this;
            if(self.insertOrder.isCreate){
                //调用排程生成方法
                self.insertOrderTimeInterval(self.insertOrder.showTime);
                
                self.closeInsertOrderPopover();
            }else{
                self.$message({
                            message: '当前任务设备在该时间有排程，请重新选择插单开始时间...',
                            type: 'success'
                    });
            }
        },
        //关闭插单浮窗
        closeInsertOrderPopover(){
            let self = this;
            self.insertOrder.isShow =  false;
        },
        //关闭查询浮窗
        closeSearchPopover(){
            let self = this;
            self.searchPopoverShow = false;
            self.clearSearchPopoverHander();
        },
        //查询打开事件
        searchPopoverEvent(){
            let self = this;
            self.searchPopoverShow = true;
        },
        //设置插单功能需要的数据，通过点击
        setInsertOrder(params){
            let self = this;
            // var   res = res+"设备编号："+ params.name + "</br>"+
            //                               "生产令号："+params.value[3]+"</br>"+
            //                               "图纸号："+params.value[4]+"</br>"+
            //                               "加工面: "+params.value[5]+"</br>"+
            //                               "工序："+params.seriesName+"</br>"+
            //                              "开始时间："+date0+"</br>"+
            //                              "结束时间："+date1+"</br>"+
            //                              "状态："+state+"</br>"+
            //                              "<hr/>";
                // showTime:new Date(),
                // tid:'1',                //详情id
                // id:'2',                 //任务id
                // drawNo:'3',             //图纸号
                // productNo:'4',          //生成令号
                // nums:'5',               //加工数量
                // planCompleteDate:null,  //需求完成时间
                // startTime:'6',          //开始时间
                // endTime:'7',            //结束时间
                // macId:'8',              //设备编号
                // processFace:'1'         //加工面
                self.insertOrder.tid = params.value[6];
                self.insertOrder.id = params.value[7];
                self.insertOrder.drawNo = params.value[4];
                self.insertOrder.productNo = params.value[3];
                //self.insertOrder.nums = params.name;                  //数量  
                //self.insertOrder.planCompleteDate = params.name;      //需求完成时间
                self.insertOrder.startTime = params.name;
                self.insertOrder.endTime = params.name;
                self.insertOrder.macId = params.name;
                self.insertOrder.processFace = params.name;

            //任务id
            //详情id
            //加工面
            //开始时间
            //结束时间
            //设备编号
            //图纸号
            //产品编号
        },
        //插单点击事件
        inseartOrderEvent(){
            let self = this;
            self.sychVal = false;
            self.insertOrder.isShow = true;
        },
        //同步数据开关
        sychValEvent(val){
            let self = this;
            alert(val);
            if(val){
                self.openIntervalTime();
            }else{
                self.closeIntervalTime();
            }
        },
        //通过选择的时间查询相关甘特图
        showGanttMapByDate(val){
            //更新ganttMap的X轴的最大最小时间  
            let self = this;
            self.getDateAToZ(val);
            self.search.date = new Date(val);
            self.showGanttMap();
        },
        //初始化日期
        initDate(){
            let self = this;
            self.getDateAToZ(null);
        },
        //初始化查询排班人员信息
        initOperator(){
            let self = this;
            planApi.planTaskOperatorTTList().then(res=>{   
                self.operator.operator1 = res.content.operator1;
                self.operator.operator2 = res.content.operator2;
                self.operator.operator3 = res.content.operator3;
                self.operator.operatorData = self.operator.operator1;
                //操作人员数据（上班的人）
                let operatorData1 =  self.operator.operator1;   //早班
                let operatorData2 =  self.operator.operator2;   //白班
                let operatorData3 =  self.operator.operator3;   //夜班
                self.operatorData = operatorData1.concat(operatorData2).concat(operatorData3);
                if(self.operator.operatorData!=null && self.operator.operatorData.length!=0)
                self.operator.operator = self.operator.operatorData[0].id;
                //self.setSearchTableData();
            });
        },
        //加工相关查询表单数据
        setSearchTableData(){
            let self = this;
            //操作人员数据（上班的人）
            let operatorData1 =  self.operator.operator1;   //早班
            let operatorData2 =  self.operator.operator2;   //白班
            let operatorData3 =  self.operator.operator3;   //夜班
            let operatorData = operatorData1.concat(operatorData2).concat(operatorData3);
            //设备数据
            let macData = self.machineArrayData;
            self.operatorData = operatorData;
            //两类数据各自的数条数
            // let operatorDataTotalLength = operatorData1.length + operatorData2.length+operatorData3.length;
            // let macDataLength = macData.length;
            //表单数据存储器
            let searchTableData =  new Array(); 
            //判定两种数据谁的数据长，就先循环谁的数据作为searchTabelData的最长条数数据
            // if(macDataLength>operatorDataTotalLength){
            //     //先循环机器的数据，然后再循环操作人员的数据
            //     for (let index = 0; index < macDataLength.length; index++) {
            //         let rowJsonObj ={};
            //         const element = macDataLength[index];
            //         rowJsonObj['shift'] = '早班';
            //         rowJsonObj['macName'] = element.name;
            //         rowJsonObj['macId'] = element.id;
            //         searchTableData.push(rowJsonObj);
            //     }
            //     //当机器的数据循环完成后，继续进行人员数据的循环
            //     for (let index = 0; index < operatorData.length; index++) {
            //         let rowJsonObj ={};
            //         const element = operatorData[index];
            //         searchTableData[index]['operatorName'] = element.name;
            //         searchTableData[index]['operatorId'] = element.id;
            //     }
            // }else {
            //     //先循装填操作人的数据，然后再循环机器的数据
            //     for (let index = 0; index < operatorData.length; index++) {
            //         let rowJsonObj ={};
            //         const element = operatorData[index];
            //         rowJsonObj['shift'] = '早班';
            //         rowJsonObj['operatorName'] = element.name;
            //         rowJsonObj['operatorId'] = element.id;
            //         searchTableData.push(rowJsonObj);
            //     }
            //     //当机器的数据循环完成后，继续进行人员数据的循环
            //     for (let index = 0; index < macDataLength.length; index++) {
            //         let rowJsonObj ={};
            //         const element = macDataLength[index];
            //         searchTableData[index]['macName'] = element.name;
            //         searchTableData[index]['macId'] = element.id;
            //     }

            // }
            // self.table.data.searchTableData =  searchTableData;
        },
        //根据所传参数时间进行该时间当天0:00与24:00的时间段点获取
        getDateAToZ(date){   
            let self = this;
            let date1 = null;
            let date2 = null;
            if(date!=null){
            date1 =   new Date(new Date(date.toLocaleDateString()).getTime());
            date2 =  new Date(new Date(date.toLocaleDateString()).getTime()+24*60*60*1000-1);
            }else
            {
            date1 = new Date(new Date(new Date().toLocaleDateString()).getTime());
            date2 = new Date(new Date(new Date().toLocaleDateString()).getTime()+24*60*60*1000-1);                
            }
            let startTime = date1.getFullYear() + "-" + ((date1.getMonth() + 1) < 10 ? "0" + (date1.getMonth() + 1):(date1.getMonth() + 1))+ "-" + (date1.getDate() < 10 ? "0" + date1.getDate():date1.getDate()) + " " + (date1.getHours()<10?"0"+date1.getHours():date1.getHours()) + ":" + (date1.getMinutes()<10?"0"+date1.getMinutes():date1.getMinutes()) + ":" + (date1.getSeconds()<10?"0"+date1.getSeconds():date1.getSeconds());
            let endTime = date2.getFullYear() + '-' + (date2.getMonth() + 1) + '-' + date2.getDate() + ' ' + date2.getHours() + ':' + date2.getMinutes() + ':' + date2.getSeconds()
            //设置甘特图上面操作按钮栏 时间插件el-date-picker 默认展示当天时间 年-月-日《= showTime
            self.search.showTime = startTime;
            //设置甘特图X轴开始时间与结束时间，默认进入页面获取当天时间的0点和23点59分59秒作为开始和结束时间
            self.grid.XstartTime = startTime;
            self.grid.XendTime = endTime;
        },
        //根据所传类型获取所传时间的起止时间 type='start'|'end'
        getDateByType(date,type){
            let date0 = null;
            let res = null;
            if(date!=null){
                date0 = date;
            }else{
                date0 = new Date();
            }
            if(type==='start'){
             date0 = new Date(new Date(date0.toLocaleDateString()).getTime());
             res = date0.getFullYear() + "-" + ((date0.getMonth() + 1) < 10 ? "0" + (date0.getMonth() + 1):(date0.getMonth() + 1))+ "-" + (date0.getDate() < 10 ? "0" + date0.getDate():date0.getDate()) + " " + (date0.getHours()<10?"0"+date0.getHours():date0.getHours()) + ":" + (date0.getMinutes()<10?"0"+date0.getMinutes():date0.getMinutes()) + ":" + (date0.getSeconds()<10?"0"+date0.getSeconds():date0.getSeconds());
            }else{
            date0 = new Date(new Date(date0.toLocaleDateString()).getTime()+24*60*60*1000-1);
            res = date0.getFullYear() + '-' + (date0.getMonth() + 1) + '-' + date0.getDate() + ' ' + date0.getHours() + ':' + date0.getMinutes() + ':' + date0.getSeconds()
            }
            return res;
        },
        //通过传入的时间 与 类型 type='up'|'next' 获取其上一天 or 下一天
        getDateUpAndNext(date,type){
            let resDate = null;
            if(date!=null){
                if(type==='up'){
                   resDate = new Date(date.getTime() - 24*60*60*1000); //前一天
                }else
                {
                   resDate = new Date(date.getTime() + 24*60*60*1000); //后一天
                }

            }else
            {
                if(type==='up'){
                   resDate = new Date(new Date().getTime() - 24*60*60*1000); //前一天
                }else
                {
                   resDate = new Date(new Date().getTime() + 24*60*60*1000); //后一天
                }
            }
            return  resDate;
        },
        //上一天
        up(){
            let self = this;
            //获取上一天的时间
            self.getDateAToZ(self.getDateUpAndNext(new Date(self.search.showTime),'up'));
            self.search.date =self.getDateUpAndNext(new Date(self.search.date),'up');
            self.showGanttMap();
        },
        //下一天
        next(){
            let self = this;
            //获取上一天的时间
            self.getDateAToZ(self.getDateUpAndNext(new Date(self.search.showTime),'next'));
            self.search.date =self.getDateUpAndNext(new Date(self.search.date),'next');
            self.showGanttMap();        },
        //拆分工艺面对应的运行时间值，并赋值给对应表格中
        reckonAToG(row,type){
            let self = this;
            if(row.detail!=null&&row.detail!=undefined){
                let faceAToGArray = row.detail.split("|");
                return self.maticherCode(faceAToGArray,type);
            }
        },
        //进行数组对应字段判定返回
        maticherCode(arrayData,matichStr){
                if(arrayData!=null){
                    for(var j = 0; j < arrayData.length; j++) {
                      if(arrayData[j].indexOf(matichStr)!=-1){
                            return arrayData[j].split(":")[1];
                        }
                    }                 
                    
                }
        },
        //计算首次加工总时间
        reckonTime(row){
            let fristInstall = row.fristInstall;
            let fristCheck = row.fristCheck;
            let runTime = row.runTime;
            let firstTotalTime =  fristInstall+fristCheck+runTime;
            return firstTotalTime;
        },
        //计算用时间
        complie(row){
            let self =  this;
            let nums =  self.table.currentPlanFousRow.nums;
            let planCompleteDate = self.table.currentPlanFousRow.planCompleteDate;
            let fristInstall = row.fristInstall;//首次装夹对刀时间
            let fristCheck = row.fristCheck;//首检时间
            let install = row.install;//装夹对刀时间
            let runTime = row.runTime;//运行时间
            //计算完成需要用多少时间 exp：时、分、秒
            //           首次装夹+首检时间+（装夹对刀时间+运行时间）乘以（生成数量-1 附注：-1为首次装夹的时间）
            let maxMin = fristInstall+fristCheck+(install+runTime)*(nums-1);
            //本地化时间
            let hour = parseInt(maxMin/60);
            let min = maxMin%60;
            return hour+"小时"+min+"分";
        },
        //初始化
        init(){
            let self = this;
            //alert(self.table.initTime);
            self.initPlanTable();
            self.initDate();
            self.initWebSocket();
            self.initOperator();
            self.queryMacCache();
            //self.queryGanttMap();
            self.listenerForClikcGanttMap();
        },
        //查看详情
        seeDetaill(){
            alert(1111);
        },
        //初始化机器下拉单
        initMacNo(){
            let self = this;
            for(var i=0;i<self.machineArrayData.length;i++){
                self.grid.YAxisData.push(self.machineArrayData[i].id);
                //  self.table.data.macSelectData.push(i);
            }
            self.setSearchTableData();
            self.queryGanttMap();
        },
        //查询机器设备信息进行缓存
        queryMacCache(){
            let self = this;
            planApi.planTaskMacList().then(res=>{
                self.machineArrayData = res.content;
                self.initMacNo();
            });
        },
        pickerOptions(){},
        //点击表格分页页数处理
        planCurrentChange(currentPage){
            let self = this;
            self.table.pagination.currentPage = currentPage;
            self.initPlanTable();
        },
        //点击表格分页每页显示多少条数据处理
        planSizeChange(size){
            let self = this;
            self.table.pagination.pageSize = size;
            self.initPlanTable();
        },
        //初始化planTable
        initPlanTable(){
            let self = this;
            let params={
                currentPage:self.table.pagination.currentPage,
                pageSize:self.table.pagination.pageSize,
                drawNo:self.table.search.drawNo,
                productNo:self.table.search.productNo 
            };
            planApi.planTaskList(params).then(res=>{
                //默认设置后台查询的第一条数据的id、图号、生产令号为查询参数
                self.table.search.planTable.id = res.content.records[0].id;
                self.table.search.planTable.drawNo = res.content.records[0].drawNo;
                self.table.search.planTable.productNo = res.content.records[0].productNo;
                //默认设置后台查询的第一条数据的图纸号、生产令号、生产数量、客户需求完成时间
                // self.table.currentPlanFousRow.productNo = res.content.records[0].productNo;
                // self.table.currentPlanFousRow.drawNo = res.content.records[0].drawNo;
                // self.table.currentPlanFousRow.nums = res.content.records[0].nums;
                // self.table.currentPlanFousRow.planCompleteDate = res.content.records[0].planCompleteDate;
                self.table.data.planTableData = res.content.records;
                self.table.pagination.total = res.content.total;
                //默认设置后台查询的第一条数据的图纸号、生产令号、生产数量、客户需求完成时间
                if(res.content.records[0].id!=null&&res.content.records[0].id!=undefined)
                self.planTableRowClick(res.content.records[0],res.content.records[0].id);
            });

        },
        //点击planTable的行触发调用方法
        planTableRowClick(row,tid){
            let self = this;
            self.isInsertOrderBottom = false;
            let vrow =  row;
            if(row==null||row===undefined){
                vrow = new Object();
                vrow.id = tid;
            }else{
                //插单功能需要的变量信息
                self.insertOrder.id =  vrow.id;
                self.insertOrder.totalId =  vrow.totalId;
                self.insertOrder.drawNo =  vrow.drawNo;
                self.insertOrder.productNo =  vrow.productNo;
                self.insertOrder.nums =  vrow.nums;
                self.insertOrder.planCompleteDate =  vrow.planCompleteDate;
                self.insertOrder.startTime = self.timestampToTime(new Date(),'yyyy-mm-dd hh:mm:ss');
                self.insertOrder.endTime =  vrow.planCompleteDate;
                self.insertOrder.type =  2;        //先默认为插单类型为type =2 ,表示该任务没有加工面，需要用户自己填写 将该计划到某设备从什么时候啊开始到什么时候结束


                //默认设置后台查询的第一条数据的id,图纸号、生产令号、生产数量、客户需求完成时间
                self.table.currentPlanFousRow.totalId = vrow.totalId;
                self.table.currentPlanFousRow.id = vrow.id;
                self.table.currentPlanFousRow.productNo = vrow.productNo;
                self.table.currentPlanFousRow.drawNo = vrow.drawNo;
                self.table.currentPlanFousRow.nums = vrow.nums;
                self.table.currentPlanFousRow.planCompleteDate = vrow.planCompleteDate;
            }
            //查询该任务id下加工面的数据，如果有加工面，则将type=1，表示有加工面的，需要零碎的计算各个加工面的首次装夹、运行、首检、装夹的时间分段
            planApi.planTaskDetailList(vrow.id,vrow.totalId).then(res=>{
                if(res.content!=null){
                    self.insertOrder.type =  1;             
                    self.table.data.septTableData = res.content;
                }else{
                    self.insertOrder.type =  2;             
                    self.table.data.septTableData = [];
                }
            });
        },
        //点击planTable的行触发调用方法
        septTableRowClick(row){
            let self = this;
            self.isInsertOrderBottom = false;
                //插单功能需要的变量信息
                // insertOrder:{
                // tid:'1',                //详情id
                // id:'2',                 //任务id
                // drawNo:'3',             //图纸号
                // productNo:'4',          //生成令号
                // nums:'5',               //加工数量
                // planCompleteDate:''     //完成时间
                // startTime:'6',          //开始时间
                // endTime:'7',            //结束时间
                // macId:'8',              //设备编号
                // processFace:'1'         //加工面
                // },
            //进行当前行数据如果要插单需要的逻辑参数赋值 ↓
            self.insertOrder.macId = row.macId;
            self.insertOrder.tid = row.id;
            self.insertOrder.processFace = row.processFace;
            self.insertOrder.fristInstall = row.fristInstall;
            self.insertOrder.install = row.install;
            self.insertOrder.runTime = row.runTime;
            self.insertOrder.fristCheck = row.fristCheck;

            let techReq = new Object;
             techReq.name = "   要求:"+ row.techReq;
            //进行该加工面刀片信息查询，有的就展示，没有则只展示技术要求 
            planApi.planTaskCutterList(row.id).then(res=>{
                self.table.data.cutterTableData = res.content;
                self.table.data.cutterTableData.unshift(techReq);
            });
        },
        //进行列表合并
        arraySpanMethod({ row, column, rowIndex, columnIndex }) {
            if (rowIndex  === 0) {
                if (columnIndex === 0) {
                    return [1, 7];
                }
            }
        },
        handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
        },
        //septTable机器设备编号选择下拉框change事件处理
        dealSelectEventForChange(row){
            let self = this;
            self.isInsertOrderBottom = false;
            //与插单设备进行联动
            self.insertOrder.macId = row.macId;
            self.isPlan = true;
            //计算当前设备的完成任务时间
                //获取当前设备最近任务的完成时间，
                //1.判定是否是今天，如果是昨天完成的时间，则重置其开始时间为当前时间+休息时间，如果是今天，则判断其完成时间是否大于当前系统时间，如果在相差值之内，则可以选择！
                let macNearCompleteTaskDate = self.maticherMachineNearTaskCompleteDate(row.macId); //通过后台接口返回当前设备最近一次任务的完成时间；
                //2.进行最近一次任务完成时间+定制的间隔时间，作为本次甘特图的开始时间
                let startTime =  new Date(macNearCompleteTaskDate.valueOf()+self.sperator*60*1000);
                let minTime = self.complieEndTime(row);
                let endTime = new Date(startTime.valueOf()+minTime*60*1000);
                //row.finishDate = endTime;
           
                //修改甘特图的开始和结束时间
                    //self.grid.XstartTime = startTime;
                    //self.grid.XendTime =  endTime;
                //创建甘特图数据
                
                row.finishDate = self.computeTimeInterval(row,startTime,endTime);
                //判断排程计划完成时间是否小于客户需求完成时间，true 是黑色，false（完成超时，完成时间比客户需求完成时间还长，则更改表格计划完成时间字段为红色）
                if(row.finishDate<new Date(self.table.currentPlanFousRow.planCompleteDate)){
                    row.className = 'black';
                }else{
                    row.className = 'red';
                    self.isPlanTimeOut=true;    //有单子超时了
                }
                //self.createGanttSeriesData(row,startTime,endTime);
                //self.checkTheTime(macNearCompleteTaskDate);
               //console.log(self.maticherMachineNearTaskCompleteDate(row.macId)) ;
        },
        //插单加工各个时段的数据
        insertOrderTimeInterval(startTime){
                // showTime:new Date(),    //需要插入时间
                // tid:'1',                //详情id
                // id:'2',                 //任务id
                // drawNo:'3',             //图纸号
                // productNo:'4',          //生成令号
                // nums:'5',               //加工数量
                // planCompleteDate:null,  //需求完成时间
                // startTime:'6',          //开始时间
                // endTime:'7',            //结束时间
                // macId:'8',              //设备编号
                // processFace:'1',        //加工面
                // startMacTime:'',           //当前所选设备所选时间在已存储的排程时间段开始时间
                // endMacTime:'',             //当前所选设备所选时间在已存储的排程时间段结束时间
            
            let index=0;
            let self =  this;
             //重置数据
            self.gantt.fristInstall=[];
            self.gantt.install=[];
            self.gantt.fristCheck=[];
            self.gantt.runTime=[];
            self.save.fristInstall=[];
            self.save.install=[];
            self.save.fristCheck=[];
            self.save.runTime=[];
            if( self.insertOrder.type == 1){
                let color = 2;
                let row = new Object();
                let processFace = self.insertOrder.processFace;                       //加工面
                let totalId = self.insertOrder.totalId; //总生产id
                let productNo = self.insertOrder.productNo; //生产令号
                let drawNo = self.insertOrder.drawNo;       //图纸号
                let nums = self.insertOrder.nums;  //需求加工的数量 通过前端点击表格行事件动态赋值被点击的行数据给nums
                let macId  = self.insertOrder.macId;
                let endTime = startTime;
                    row.fristInstall =  self.insertOrder.fristInstall;
                    row.install =  self.insertOrder.install;
                    row.runTime =  self.insertOrder.runTime;
                    row.fristCheck =  self.insertOrder.fristCheck;
                    row.tid = self.insertOrder.id;
                    row.id = self.insertOrder.tid;
                let fristInstall = row.fristInstall;     //第一次装夹对刀时间 |分钟
                let fristStartTime = startTime;
                let fristInstallEndTime = new Date(startTime.valueOf()+fristInstall*60*1000);
                let fristInstallDataObject={};
                let fristInstallData=[];
                    fristInstallData.unshift(totalId);               //总生产id 对应后台task_total
                    fristInstallData.unshift(row.install);           //装夹
                    fristInstallData.unshift(row.runTime);           //运行时间
                    fristInstallData.unshift(row.fristCheck);        //首检
                    fristInstallData.unshift(row.fristInstall);      //首次装夹
                    fristInstallData.unshift(color);      //颜色 0 浅蓝 1 青草 2 蔷薇红
                    fristInstallData.unshift(index++);    //序号
                    fristInstallData.unshift(endTime);    //整个任务结束时间
                    fristInstallData.unshift(startTime);  //整个任务开始时间
                    fristInstallData.unshift(row.tid);    //任务id
                    fristInstallData.unshift(row.id);     //任务详情id
                    fristInstallData.unshift(processFace);//加工面
                    fristInstallData.unshift(drawNo);     //图纸号
                    fristInstallData.unshift(productNo);  //生产令号
                    fristInstallData.unshift(fristInstallEndTime); //各个小甘特图小节点的开始时间
                    fristInstallData.unshift(fristStartTime);      //各个小甘特图小节点的结束时间
                    fristInstallData.unshift(macId+'');   //设备编号
                fristInstallDataObject.name=macId+'';
                fristInstallDataObject.value=fristInstallData;
                self.save.fristInstall.push(fristInstallDataObject);
                let install = row.install;               //装夹对刀时间   |分钟
    
                let runTime = row.runTime;               //程序运行时间   |分钟  
                let fristRunTimeStartTime =  fristInstallEndTime;
                let fristRunTimeEndTime = new Date(fristInstallEndTime.valueOf()+runTime*60*1000); 
                let fristRunTimeDataObject={};
                let fristRunTimeData=[];
                    fristRunTimeData.unshift(totalId);               //总生产id
                    fristRunTimeData.unshift(row.install);           //装夹
                    fristRunTimeData.unshift(row.runTime);           //运行时间
                    fristRunTimeData.unshift(row.fristCheck);        //首检
                    fristRunTimeData.unshift(row.fristInstall);      //首次装夹
                    fristRunTimeData.unshift(color);      //颜色 0 浅蓝 1 青草 2 蔷薇红
                    fristRunTimeData.unshift(index++);    //序号
                    fristRunTimeData.unshift(endTime);    //整个任务结束时间
                    fristRunTimeData.unshift(startTime);  //整个任务开始时间
                    fristRunTimeData.unshift(row.tid);  //任务id
                    fristRunTimeData.unshift(row.id);  //任务详情id
                    fristRunTimeData.unshift(processFace);
                    fristRunTimeData.unshift(drawNo);
                    fristRunTimeData.unshift(productNo);
                    fristRunTimeData.unshift(fristRunTimeEndTime);
                    fristRunTimeData.unshift(fristRunTimeStartTime);
                    fristRunTimeData.unshift(macId+'');
                fristRunTimeDataObject.name=macId+'';
                fristRunTimeDataObject.isFrist = 1;                  //是否是首次程序运行 1是 
                fristRunTimeDataObject.value=fristRunTimeData;
                self.save.runTime.push(fristRunTimeDataObject);
    
                let fristCheck = row.fristCheck;         //首检用时       |分钟 
    
                let fristCheckStartTime = fristRunTimeEndTime;
                let fristCheckEndTime =  new Date(fristCheckStartTime.valueOf()+fristCheck*60*1000);
                let fristCheckDataObject={};
                let fristCheckData=[];
                    fristCheckData.unshift(totalId);               //总生产id
                    fristCheckData.unshift(row.install);           //装夹
                    fristCheckData.unshift(row.runTime);           //运行时间
                    fristCheckData.unshift(row.fristCheck);        //首检
                    fristCheckData.unshift(row.fristInstall);      //首次装夹
                    fristCheckData.unshift(color);      //颜色 0 浅蓝 1 青草 2 蔷薇红
                    fristCheckData.unshift(index++);    //序号
                    fristCheckData.unshift(endTime);    //整个任务结束时间
                    fristCheckData.unshift(startTime);  //整个任务开始时间
                    fristCheckData.unshift(row.tid);  //任务id
                    fristCheckData.unshift(row.id);  //任务详情id
                    fristCheckData.unshift(processFace);
                    fristCheckData.unshift(drawNo);
                    fristCheckData.unshift(productNo);
                    fristCheckData.unshift(fristCheckEndTime);
                    fristCheckData.unshift(fristCheckStartTime);
                    fristCheckData.unshift(macId+'');
                fristCheckDataObject.name=macId+'';
                fristCheckDataObject.value=fristCheckData;
                self.save.fristCheck.push(fristCheckDataObject);
                //-----------------第一次特殊处理----------------------↑
    
                //-----------------后序则没有第一次装夹和首检了，只有加工数量减去第一件的数量-1 进行装夹+运行递归算法---------------------↓
                    //装夹
                // let installStartTime = fristCheckEndTime;
                let installStartTime = fristRunTimeEndTime;
                let installEndTime  = new Date(installStartTime.valueOf()+install*60*1000);
                    let installDataObject={};  
                    let installData=[];
                        installData.unshift(totalId);               //总生产id
                        installData.unshift(row.install);           //装夹
                        installData.unshift(row.runTime);           //运行时间
                        installData.unshift(row.fristCheck);        //首检
                        installData.unshift(row.fristInstall);      //首次装夹
                        installData.unshift(color);      //颜色 0 浅蓝 1 青草 2 蔷薇红
                        installData.unshift(index++);    //序号
                        installData.unshift(endTime);    //整个任务结束时间
                        installData.unshift(startTime);  //整个任务开始时间
                        installData.unshift(row.tid);  //任务id
                        installData.unshift(row.id);  //任务详情id
                        installData.unshift(processFace);
                        installData.unshift(drawNo);
                        installData.unshift(productNo);
                        installData.unshift(installEndTime);
                        installData.unshift(installStartTime);
                        installData.unshift(macId+'');
                    installDataObject.name=macId+'';
                    installDataObject.value=installData;
                    self.save.install.push(installDataObject);
                    //运行             
                    let runTimeDataObject={};               
                    let runTimeData=[];     
                    let runTimeStartTime=installEndTime;  
                    let runTimeEndTime=new Date(runTimeStartTime.valueOf()+runTime*60*1000);
                        runTimeData.unshift(totalId);               //总生产id
                        runTimeData.unshift(row.install);           //装夹
                        runTimeData.unshift(row.runTime);           //运行时间
                        runTimeData.unshift(row.fristCheck);        //首检
                        runTimeData.unshift(row.fristInstall);      //首次装夹
                        runTimeData.unshift(color);      //颜色 0 浅蓝 1 青草 2 蔷薇红
                        runTimeData.unshift(index++);    //序号
                        runTimeData.unshift(endTime);    //整个任务结束时间
                        runTimeData.unshift(startTime);  //整个任务开始时间
                        runTimeData.unshift(row.tid);  //任务id
                        runTimeData.unshift(row.id);  //任务详情id
                        runTimeData.unshift(processFace);
                        runTimeData.unshift(drawNo);
                        runTimeData.unshift(productNo);
                        runTimeData.unshift(runTimeEndTime);
                        runTimeData.unshift(runTimeStartTime);
                        runTimeData.unshift(macId+'');
                    runTimeDataObject.name=macId+'';
                    runTimeDataObject.value=runTimeData;
                    self.save.runTime.push(runTimeDataObject);  
                let installLoopStartTime =    runTimeEndTime;  
                let installLoopEndTime =   new Date(installLoopStartTime.valueOf()+runTime*60*1000);
                let runTimeLoopStartTime =    null;  
                let runTimeLoopEndTime =   null;
                for (let i = 0; i < nums-2; i++) {
                    //循环加工装夹数据
                    let installDataObject={};  
                    let installData=[];
                            installData.unshift(totalId);               //总生产id
                            installData.unshift(row.install);           //装夹
                            installData.unshift(row.runTime);           //运行时间
                            installData.unshift(row.fristCheck);        //首检
                            installData.unshift(row.fristInstall);      //首次装夹
                            installData.unshift(color);      //颜色 0 浅蓝 1 青草 2 蔷薇红
                            installData.unshift(index++);    //序号
                            installData.unshift(endTime);    //整个任务结束时间
                            installData.unshift(startTime);  //整个任务开始时间
                            installData.unshift(row.tid);  //任务id
                            installData.unshift(row.id);  //任务详情id
                            installData.unshift(processFace);
                            installData.unshift(drawNo);
                            installData.unshift(productNo);
                            installData.unshift(installLoopEndTime);
                            installData.unshift(installLoopStartTime);
                            installData.unshift(macId+'');
                        installDataObject.name=macId+'';
                        installDataObject.value=installData;
                        self.save.install.push(installDataObject);
                    //循环加工运行数据
                    let runTimeDataObject={};               
                    let runTimeData=[];     
                    runTimeLoopStartTime = installLoopEndTime;  
                    installLoopStartTime = runTimeLoopEndTime = new Date(self.timestampToTime(runTimeLoopStartTime.valueOf()+runTime*60*1000,'yyyy-mm-dd hh:mm:ss'));
                        runTimeData.unshift(totalId);               //总生产id
                        runTimeData.unshift(row.install);           //装夹
                        runTimeData.unshift(row.runTime);           //运行时间
                        runTimeData.unshift(row.fristCheck);        //首检
                        runTimeData.unshift(row.fristInstall);      //首次装夹
                        runTimeData.unshift(color);      //颜色 0 浅蓝 1 青草 2 蔷薇红
                        runTimeData.unshift(index++);    //序号
                        runTimeData.unshift(endTime);    //整个任务结束时间
                        runTimeData.unshift(startTime);  //整个任务开始时间
                        runTimeData.unshift(row.tid);  //任务id
                        runTimeData.unshift(row.id);  //任务详情id
                        runTimeData.unshift(processFace);
                        runTimeData.unshift(drawNo);
                        runTimeData.unshift(productNo);
                        runTimeData.unshift(runTimeLoopEndTime);
                        runTimeData.unshift(runTimeLoopStartTime);
                        runTimeData.unshift(macId+'');
                    runTimeDataObject.name=macId+'';
                    runTimeDataObject.value=runTimeData;
                    self.save.runTime.push(runTimeDataObject);  
                    installLoopEndTime =new Date(self.timestampToTime(installLoopStartTime.valueOf()+install*60*1000,'yyyy-mm-dd hh:mm:ss'));
                }
                self.saveInsertOrder();
                return runTimeLoopEndTime;
            }else 
            if( self.insertOrder.type == 2){

            }
            //调用保存数据
            //self.savePlan();
        },
        //加工各个时段的数据
        computeTimeInterval(row,startTime,endTime){
            let index=0;
            let self =  this;
            let color = 2;
            let processFace = row.processFace;                       //加工面
            let totalId = self.table.currentPlanFousRow.totalId; //总生产id
            let productNo = self.table.currentPlanFousRow.productNo; //生产令号
            let drawNo = self.table.currentPlanFousRow.drawNo;       //图纸号
            let nums = self.table.currentPlanFousRow.nums;  //需求加工的数量 通过前端点击表格行事件动态赋值被点击的行数据给nums
            let macId  =  row.macId;
            let fristInstall = row.fristInstall;     //第一次装夹对刀时间 |分钟
            let fristStartTime = startTime;
            let fristInstallEndTime = new Date(startTime.valueOf()+fristInstall*60*1000);
            let fristInstallDataObject={};
            let fristInstallData=[];
                fristInstallData.unshift(totalId);           //total计划 ID
                fristInstallData.unshift(row.install);           //装夹
                fristInstallData.unshift(row.runTime);           //运行时间
                fristInstallData.unshift(row.fristCheck);        //首检
                fristInstallData.unshift(row.fristInstall);      //首次装夹
                fristInstallData.unshift(color);      //颜色 0 浅蓝 1 青草 2 蔷薇红
                fristInstallData.unshift(index++);    //序号
                fristInstallData.unshift(endTime);    //整个任务结束时间
                fristInstallData.unshift(startTime);  //整个任务开始时间
                fristInstallData.unshift(row.tid);  //任务id
                fristInstallData.unshift(row.id);  //任务详情id
                fristInstallData.unshift(processFace);
                fristInstallData.unshift(drawNo);
                fristInstallData.unshift(productNo);
                fristInstallData.unshift(fristInstallEndTime); //各个小甘特图小节点的开始时间
                fristInstallData.unshift(fristStartTime);      //各个小甘特图小节点的结束时间
                fristInstallData.unshift(macId+'');
            fristInstallDataObject.name=macId+'';
            fristInstallDataObject.value=fristInstallData;
            self.gantt.fristInstall.push(fristInstallDataObject);
            self.save.fristInstall.push(fristInstallDataObject);
            let install = row.install;               //装夹对刀时间   |分钟

            let runTime = row.runTime;               //程序运行时间   |分钟  
            let fristRunTimeStartTime =  fristInstallEndTime;
            let fristRunTimeEndTime = new Date(fristInstallEndTime.valueOf()+runTime*60*1000); 
            let fristRunTimeDataObject={};
            let fristRunTimeData=[];
                fristRunTimeData.unshift(totalId);           //total计划 ID
                fristRunTimeData.unshift(row.install);           //装夹
                fristRunTimeData.unshift(row.runTime);           //运行时间
                fristRunTimeData.unshift(row.fristCheck);        //首检
                fristRunTimeData.unshift(row.fristInstall);      //首次装夹
                fristRunTimeData.unshift(color);      //颜色 0 浅蓝 1 青草 2 蔷薇红
                fristRunTimeData.unshift(index++);    //序号
                fristRunTimeData.unshift(endTime);    //整个任务结束时间
                fristRunTimeData.unshift(startTime);  //整个任务开始时间
                fristRunTimeData.unshift(row.tid);  //任务id
                fristRunTimeData.unshift(row.id);  //任务详情id
                fristRunTimeData.unshift(processFace);
                fristRunTimeData.unshift(drawNo);
                fristRunTimeData.unshift(productNo);
                fristRunTimeData.unshift(fristRunTimeEndTime);
                fristRunTimeData.unshift(fristRunTimeStartTime);
                fristRunTimeData.unshift(macId+'');
            fristRunTimeDataObject.name=macId+'';
            fristRunTimeDataObject.isFrist = 1;                  //是否是首次程序运行 1是 
            fristRunTimeDataObject.value=fristRunTimeData;
            self.gantt.runTime.push(fristRunTimeDataObject);
            self.save.runTime.push(fristRunTimeDataObject);

            let fristCheck = row.fristCheck;         //首检用时       |分钟 

            let fristCheckStartTime = fristRunTimeEndTime;
            let fristCheckEndTime =  new Date(fristCheckStartTime.valueOf()+fristCheck*60*1000);
            let fristCheckDataObject={};
            let fristCheckData=[];
                fristCheckData.unshift(totalId);           //total计划 ID
                fristCheckData.unshift(row.install);           //装夹
                fristCheckData.unshift(row.runTime);           //运行时间
                fristCheckData.unshift(row.fristCheck);        //首检
                fristCheckData.unshift(row.fristInstall);      //首次装夹
                fristCheckData.unshift(color);      //颜色 0 浅蓝 1 青草 2 蔷薇红
                fristCheckData.unshift(index++);    //序号
                fristCheckData.unshift(endTime);    //整个任务结束时间
                fristCheckData.unshift(startTime);  //整个任务开始时间
                fristCheckData.unshift(row.tid);  //任务id
                fristCheckData.unshift(row.id);  //任务详情id
                fristCheckData.unshift(processFace);
                fristCheckData.unshift(drawNo);
                fristCheckData.unshift(productNo);
                fristCheckData.unshift(fristCheckEndTime);
                fristCheckData.unshift(fristCheckStartTime);
                fristCheckData.unshift(macId+'');
            fristCheckDataObject.name=macId+'';
            fristCheckDataObject.value=fristCheckData;
            self.gantt.fristCheck.push(fristCheckDataObject);
            self.save.fristCheck.push(fristCheckDataObject);
            //-----------------第一次特殊处理----------------------↑

            //-----------------后序则没有第一次装夹和首检了，只有加工数量减去第一件的数量-1 进行装夹+运行递归算法---------------------↓
                //装夹
            let installStartTime = fristRunTimeEndTime;
            let installEndTime  = new Date(installStartTime.valueOf()+install*60*1000);
                let installDataObject={};  
                let installData=[];
                    installData.unshift(totalId);           //total计划 ID
                    installData.unshift(row.install);           //装夹
                    installData.unshift(row.runTime);           //运行时间
                    installData.unshift(row.fristCheck);        //首检
                    installData.unshift(row.fristInstall);      //首次装夹
                    installData.unshift(color);      //颜色 0 浅蓝 1 青草 2 蔷薇红
                    installData.unshift(index++);    //序号
                    installData.unshift(endTime);    //整个任务结束时间
                    installData.unshift(startTime);  //整个任务开始时间
                    installData.unshift(row.tid);  //任务id
                    installData.unshift(row.id);  //任务详情id
                    installData.unshift(processFace);
                    installData.unshift(drawNo);
                    installData.unshift(productNo);
                    installData.unshift(installEndTime);
                    installData.unshift(installStartTime);
                    installData.unshift(macId+'');
                installDataObject.name=macId+'';
                installDataObject.value=installData;
                self.gantt.install.push(installDataObject);
                self.save.install.push(installDataObject);
                //运行             
                let runTimeDataObject={};               
                let runTimeData=[];     
                let runTimeStartTime=installEndTime;  
                let runTimeEndTime=new Date(runTimeStartTime.valueOf()+runTime*60*1000);
                    runTimeData.unshift(totalId);           //total计划 ID
                    runTimeData.unshift(row.install);           //装夹
                    runTimeData.unshift(row.runTime);           //运行时间
                    runTimeData.unshift(row.fristCheck);        //首检
                    runTimeData.unshift(row.fristInstall);      //首次装夹
                    runTimeData.unshift(color);      //颜色 0 浅蓝 1 青草 2 蔷薇红
                    runTimeData.unshift(index++);    //序号
                    runTimeData.unshift(endTime);    //整个任务结束时间
                    runTimeData.unshift(startTime);  //整个任务开始时间
                    runTimeData.unshift(row.tid);  //任务id
                    runTimeData.unshift(row.id);  //任务详情id
                    runTimeData.unshift(processFace);
                    runTimeData.unshift(drawNo);
                    runTimeData.unshift(productNo);
                    runTimeData.unshift(runTimeEndTime);
                    runTimeData.unshift(runTimeStartTime);
                    runTimeData.unshift(macId+'');
                runTimeDataObject.name=macId+'';
                runTimeDataObject.value=runTimeData;
                self.gantt.runTime.push(runTimeDataObject);  
                self.save.runTime.push(runTimeDataObject);  
            let installLoopStartTime =    runTimeEndTime;  
            let installLoopEndTime =   new Date(installLoopStartTime.valueOf()+runTime*60*1000);
            let runTimeLoopStartTime =    null;  
            let runTimeLoopEndTime =   null;
            for (let i = 0; i < nums-2; i++) {
                //循环加工装夹数据
                let installDataObject={};  
                let installData=[];
                        installData.unshift(totalId);           //total计划 ID
                        installData.unshift(row.install);           //装夹
                        installData.unshift(row.runTime);           //运行时间
                        installData.unshift(row.fristCheck);        //首检
                        installData.unshift(row.fristInstall);      //首次装夹
                        installData.unshift(color);      //颜色 0 浅蓝 1 青草 2 蔷薇红
                        installData.unshift(index++);    //序号
                        installData.unshift(endTime);    //整个任务结束时间
                        installData.unshift(startTime);  //整个任务开始时间
                        installData.unshift(row.tid);  //任务id
                        installData.unshift(row.id);  //任务详情id
                        installData.unshift(processFace);
                        installData.unshift(drawNo);
                        installData.unshift(productNo);
                        installData.unshift(installLoopEndTime);
                        installData.unshift(installLoopStartTime);
                        installData.unshift(macId+'');
                    installDataObject.name=macId+'';
                    installDataObject.value=installData;
                    self.gantt.install.push(installDataObject);
                    self.save.install.push(installDataObject);
                //循环加工运行数据
                let runTimeDataObject={};               
                let runTimeData=[];     
                runTimeLoopStartTime = installLoopEndTime;  
                installLoopStartTime = runTimeLoopEndTime = new Date(self.timestampToTime(runTimeLoopStartTime.valueOf()+runTime*60*1000,'yyyy-mm-dd hh:mm:ss'));
                    runTimeData.unshift(totalId);           //total计划 ID
                    runTimeData.unshift(row.install);           //装夹
                    runTimeData.unshift(row.runTime);           //运行时间
                    runTimeData.unshift(row.fristCheck);        //首检
                    runTimeData.unshift(row.fristInstall);      //首次装夹
                    runTimeData.unshift(color);      //颜色 0 浅蓝 1 青草 2 蔷薇红
                    runTimeData.unshift(index++);    //序号
                    runTimeData.unshift(endTime);    //整个任务结束时间
                    runTimeData.unshift(startTime);  //整个任务开始时间
                    runTimeData.unshift(row.tid);  //任务id
                    runTimeData.unshift(row.id);  //任务详情id
                    runTimeData.unshift(processFace);
                    runTimeData.unshift(drawNo);
                    runTimeData.unshift(productNo);
                    runTimeData.unshift(runTimeLoopEndTime);
                    runTimeData.unshift(runTimeLoopStartTime);
                    runTimeData.unshift(macId+'');
                runTimeDataObject.name=macId+'';
                runTimeDataObject.value=runTimeData;
                self.gantt.runTime.push(runTimeDataObject);  
                self.save.runTime.push(runTimeDataObject);  
                installLoopEndTime =new Date(self.timestampToTime(installLoopStartTime.valueOf()+install*60*1000,'yyyy-mm-dd hh:mm:ss'));
            }
            //进行当前设备最后结束时间重置
            self.resetMacTime(macId,runTimeLoopEndTime);          
            self.showGanttMap();
            return runTimeLoopEndTime;
            // let macId = row.macId;
            // let dataObject ={};
            // let innerData=[];
            //     innerData.unshift(endTime);
            //     innerData.unshift(startTime);
            //     innerData.unshift(macId+'');
            // dataObject.name=macId+'';
            // dataObject.value=innerData;
        },
        //根据时间创建该设备号对应加工面的时间
        createGanttSeriesData(row,startTime,endTime){
            let self =  this;
            let macId = row.macId;
            let dataObject ={};
            let innerData=[];
                innerData.unshift(endTime);
                innerData.unshift(startTime);
                innerData.unshift(macId+'');
            dataObject.name=macId+'';
            dataObject.value=innerData;
            switch (row.processFace) {
                case 'A':self.gantt.A.push(dataObject); break;
                case 'B':self.gantt.B.push(dataObject); break;
                case 'C':self.gantt.C.push(dataObject); break;
                case 'D':self.gantt.D.push(dataObject); break;
                case 'E':self.gantt.E.push(dataObject); break;
                case 'F':self.gantt.F.push(dataObject); break;
                case 'G':self.gantt.G.push(dataObject); break;
                default:
                    break;
            }
            //进行当前设备最后结束时间重置
            self.resetMacTime(macId,endTime);          
            self.showGanttMap();
            //参照数据样式  ↓↓

            //  [
            //                 {
            //                     name:'23',
            //                     value: [
            //                             '23',
            //                             new Date("2019/10/28 08:00:00"),
            //                             new Date("2019/10/28 15:00:00")
            //                             ],
            //                 },
            // ]
        },
        //进行当前设备最后结束时间的更新
        resetMacTime(macId,endTime){
            let self = this;
            switch (macId+'') {
                case '1':return self.table.machine.mac1.initTime = endTime; break;
                case '2':return self.table.machine.mac2.initTime= endTime; break;
                case '3':return self.table.machine.mac3.initTime= endTime; break;
                case '4':return self.table.machine.mac4.initTime= endTime; break;
                case '5':return self.table.machine.mac5.initTime= endTime; break;
                case '6':return self.table.machine.mac6.initTime= endTime; break;
                case '7':return self.table.machine.mac7.initTime= endTime; break;
                case '8':return self.table.machine.mac8.initTime= endTime; break;
                case '9':return self.table.machine.mac9.initTime= endTime; break;
                case '10':return self.table.machine.mac10.initTime= endTime; break;
                case '11':return self.table.machine.mac11.initTime= endTime; break;
                case '12':return self.table.machine.mac12.initTime= endTime; break;
                case '13':return self.table.machine.mac13.initTime= endTime; break;
                case '14':return self.table.machine.mac14.initTime= endTime; break;
                case '15':return self.table.machine.mac15.initTime= endTime; break;
                case '16':return self.table.machine.mac16.initTime= endTime; break;
                case '17':return self.table.machine.mac17.initTime= endTime; break;
                case '18':return self.table.machine.mac18.initTime= endTime; break;
                case '19':return self.table.machine.mac19.initTime= endTime; break;
                case '20':return self.table.machine.mac20.initTime= endTime; break;
                case '21':return self.table.machine.mac21.initTime= endTime; break;
                case '22':return self.table.machine.mac22.initTime= endTime; break;
                case '23':return self.table.machine.mac23.initTime= endTime; break;
                default:
                    break;
            }
        },
        //根据所传设备编号获取其最近任务的完成时间=》该时间通过进入页面初始化甘特图数据时候从后台获取 machineNo =》macId 参数对应后台数据返回key
        maticherMachineNearTaskCompleteDate(machineNo){
            let self = this;
            switch (machineNo+'') {    
                case '1':return self.table.machine.mac1.initTime; break;
                case '2':return self.table.machine.mac2.initTime; break;
                case '3':return self.table.machine.mac3.initTime; break;
                case '4':return self.table.machine.mac4.initTime; break;
                case '5':return self.table.machine.mac5.initTime; break;
                case '6':return self.table.machine.mac6.initTime; break;
                case '7':return self.table.machine.mac7.initTime; break;
                case '8':return self.table.machine.mac8.initTime; break;
                case '9':return self.table.machine.mac9.initTime; break;
                case '10':return self.table.machine.mac10.initTime; break;
                case '11':return self.table.machine.mac11.initTime; break;
                case '12':return self.table.machine.mac12.initTime; break;
                case '13':return self.table.machine.mac13.initTime; break;
                case '14':return self.table.machine.mac14.initTime; break;
                case '15':return self.table.machine.mac15.initTime; break;
                case '16':return self.table.machine.mac16.initTime; break;
                case '17':return self.table.machine.mac17.initTime; break;
                case '18':return self.table.machine.mac18.initTime; break;
                case '19':return self.table.machine.mac19.initTime; break;
                case '20':return self.table.machine.mac20.initTime; break;
                case '21':return self.table.machine.mac21.initTime; break;
                case '22':return self.table.machine.mac22.initTime; break;
                case '23':return self.table.machine.mac23.initTime; break;
                default:
                    break;
            }

        },
        //test测试重置时间
        testResetMacTime(){
            let self = this;
            let date =  new Date();
            self.table.machine.mac1.initTime = date;
            self.table.machine.mac2.initTime = date;
            self.table.machine.mac3.initTime = date;
            self.table.machine.mac4.initTime = date;
            self.table.machine.mac5.initTime = date;
            self.table.machine.mac6.initTime = date;
            self.table.machine.mac7.initTime = date;
            self.table.machine.mac8.initTime = date;
            self.table.machine.mac9.initTime = date;
            self.table.machine.mac10.initTime = date;
            self.table.machine.mac11.initTime = date;
            self.table.machine.mac12.initTime = date;
            self.table.machine.mac13.initTime = date;
            self.table.machine.mac14.initTime = date;
            self.table.machine.mac15.initTime = date;
            self.table.machine.mac16.initTime = date;
            self.table.machine.mac17.initTime = date;
            self.table.machine.mac18.initTime = date;
            self.table.machine.mac19.initTime = date;
            self.table.machine.mac20.initTime = date;
            self.table.machine.mac21.initTime = date;
            self.table.machine.mac22.initTime = date;
            self.table.machine.mac23.initTime = date;
        },
        //通过行参数值进行具体工艺耗时计算
        complieEndTime(row){
            let self = this;
            //1.获取需要加工任务数量，图纸号，生产令号，客户需求完成时间（已获取，通过前面点击任务任务表格行函数 planTableRowClick 进行赋值给 table.currentPlanFousRow json对象）
                //self.table.currentPlanFousRow.productNo; 
                //self.table.currentPlanFousRow.drawNo; 
                //self.table.currentPlanFousRow.nums;
                // self.table.currentPlanFousRow.planCompleteDate;
            //2.获取加工面对应的参数
            let fristTotalTime = self.reckonTime(row) //首次加工总时间 |分钟
            let install = row.install;               //装夹对刀时间   |分钟
            let runTime = row.runTime;               //程序运行时间   |分钟
            let endTime = (install+runTime)*(self.table.currentPlanFousRow.nums-1)+fristTotalTime;
            return endTime;
        },
        //判断所传参数时间是否比当前时间小
        checkTheTime(date){
            if(date!=null&&date!=undefined){
                //获取当前时间
                let currentDate = new Date();
                //对比所传时间是否比当前时间小 ，如果小，则默认为false
            }else{
                return true;
            }
        },
        //展示甘特图
        showGanttMap(){
            let self = this;
            self.queryGanttMap();
        },
        //刷新重置甘特图
        restGanttMap(){
            let self = this;
            self.isPlan = false;
            self.selectSperatorArray=[];
            self.operator.planResultId = null;
            self.gantt.A=[];
            self.gantt.B=[];
            self.gantt.C=[];
            self.gantt.D=[];
            self.gantt.E=[];
            self.gantt.F=[];
            self.gantt.G=[];
            self.gantt.fristInstall=[];
            self.gantt.install=[];
            self.gantt.fristCheck=[];
            self.gantt.runTime=[];
            self.save.fristInstall=[];
            self.save.install=[];
            self.save.fristCheck=[];
            self.save.runTime=[];
            self.ganttChart.clear();
            self.restInsertOrder();     //重置插单功能信息
            self.restfuSpetTable();  
            self.testResetMacTime();    //重置所有机器的开始时间为当前时间
            self.isPlanTimeOut = false;
            self.showGanttMap();
        },
        //重置插单信息
        restInsertOrder(){
            let self = this;
            self.insertOrder.showTime = new Date();
            self.insertOrder.tid='';
            self.insertOrder.id='';
            self.insertOrder.drawNo='';
            self.insertOrder.productNo='';
            self.insertOrder.nums='';
            self.insertOrder.planCompleteDate='';
            self.insertOrder.startTime='';
            self.insertOrder.endTime='';
            self.insertOrder.startMacTime='';
            self.insertOrder.endMacTime='';
            self.insertOrder.macId='';
            self.insertOrder.processFace='';
        },
        //queryGanttMap图的数据
        queryGanttMap(){
            let self = this;
            let date = self.timestampToTime(self.search.date,'yyyy-mm-dd') ;
            planApi.planTaskGanTTList(date).then(res=>{
                // let content =eval('('+res+')');
                // console.log(res);
                let content = JSON.parse(res.content);
                //1进行查询数据的备份存储
                self.original.fristInstall = content.planResults.fristInstall;
                self.original.install = content.planResults.install;
                self.original.runTime = content.planResults.runTime;
                self.original.fristCheck = content.planResults.fristCheck;
                self.original.macEndTime = content.planResults.macEndTime;
                //2进行甘特图展示数据查看
                self.gantt.fristInstall = content.planResults.fristInstall;
                self.gantt.install = content.planResults.install;
                self.gantt.runTime = content.planResults.runTime;
                self.gantt.fristCheck = content.planResults.fristCheck;
                self.gantt.macEndTime = content.planResults.macEndTime;
                //进行上次保存的数据存档
                self.gantt.fristInstall =  self.gantt.fristInstall.concat(self.save.fristInstall);
                self.gantt.install =  self.gantt.install.concat(self.save.install);
                self.gantt.runTime =  self.gantt.runTime.concat(self.save.runTime);
                self.gantt.fristCheck =  self.gantt.fristCheck.concat(self.save.fristCheck);
                self.isloading = false;
                self.initGanttMap();
                self.setInitMacTime(self.gantt.macEndTime);
            });
        },
        //根据设备编号+日期查询当前设备的排程时间相关信息
        queryGanttByMacNoTime(){
            let self = this;
            if(self.insertOrder.showTime==''||self.insertOrder.showTime==undefined){
                   self.$message({
                        message: '请确保时间与设备号已选择！',
                        type: 'success'
                    });
                    return;
            }
            if(self.insertOrder.macId==''||self.insertOrder.macId==undefined){
                   self.$message({
                        message: '请确保时间与设备号已选择！',
                        type: 'success'
                    });
                    return;
            }
            let dateStr = self.insertOrder.showTime;
            let date = self.timestampToTime(self.insertOrder.showTime,'yyyy-mm-dd hh:mm:ss') ;
            let macNo = self.insertOrder.macId;
            planApi.planTaskGanTTTime(macNo,date).then(res=>{
                let startTime = null;
                let endTime = null;
                if(res.content.status == 1){
                    self.insertOrder.isCreate =  true;
                    self.insertOrder.startMacTime =  '<span style="color:green">空闲</span>';
                    self.insertOrder.endMacTime = '';
                }else{
                    self.insertOrder.isCreate =  false;
                    self.insertOrder.startMacTime ='<span style="color:red">'+ res.content.startTime +'&nbsp;≈&nbsp;</span>';
                    self.insertOrder.endMacTime =  '<span style="color:red">'+  res.content.endTime +'</span>';
                } 
            });
        },
        //初始化甘特图
        initGanttMap(){ 
            let self = this;
            self.ganttChart = self.$echarts.init(
                document.getElementById("gantt")
            );
            self.ganttChart.clear(); //清除上次数据
            let option = self.setGanttChartOption();
            self.ganttChart.setOption(option,true);
            if(self.isfristBindEvent){
                self.listenerForClikcGanttMap();
                self.isfristBindEvent = false;
            }
        },
        //甘特图option设置
        setGanttChartOption(){
            let self =  this;
            let categories = [
                    "001",
                    "002",
                    "003",
                    "004",
                    "005",
                    "006",
                    "007",
                    "008",
                    "009",
                    "010",
                    "011",
                    "012",
                    "013",
                    "014",
                    "015",
                    "016",
                    "017",
                    "018",
                    "019",
                    "020"
                    ];
               // 绘制图表。
            let option = {
                    title: {
                        text: '工作流甘特图'
                    },
                    legend: {
                        y: 'top',
                        x:'right',
                        padding:[50,10,0,0],
                        orient:'vertical',
                        selected:{
                         首次装夹:self.trigger.isFristInstall,
                         次装夹:self.trigger.isInstall,
                         程序运行:self.trigger.isRunTime,
                         首检:self.trigger.isFristCheck
                        },
                        data: [
                         '首次装夹',
                         '次装夹',
                         '程序运行',
                         '首检'
                         ]

                    },
                    toolbox: {
                        show: true,
                        orient:'vertical',
                        itemSize:22,
                        bottom:'20',
                        feature: {
                            myTool1: {
                                show: true,
                                title: '放大',
                                icon: "image://"+big,
                                onclick: function (){
                                    // alert('myToolHandler1');
                                    // let chId = that.chartBigId 
                                    // that.chartDialog = true
                                    // that.newProviderDisplay('#chartBigId');
                                }
                            },
                            myTool2: {
                                show: true,
                                title: '缩小',
                                icon: "image://"+small,
                                onclick: function (){
                                    // alert('myToolHandler1');
                                    // let chId = that.chartBigId 
                                    // that.chartDialog = true
                                    // that.newProviderDisplay('#chartBigId');
                                }
                            }
                        }
                    },
                    grid: {
                       left: 30,
                       right: 115,
                       containLabel: false,
                    },
                    dataZoom: [
                        {
                            type: "slider",
                            filterMode: "weakFilter",
                            showDataShadow: true,
                            bottom: 15,
                            height: 5,
                            borderColor: "transparent",
                            backgroundColor: "#e2e2e2",
                            handleIcon:
                            "M10.7,11.9H9.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7v-1.2h6.6z M13.3,22H6.7v-1.2h6.6z M13.3,19.6H6.7v-1.2h6.6z",
                            handleSize: 20,
                            handleStyle: {
                            shadowBlur: 6,
                            shadowOffsetX: 1,
                            shadowOffsetY: 2,
                            shadowColor: "#aaa"
                            },
                            labelFormatter: ""
                        },
                        {
                            type: "inside",
                            filterMode: "weakFilter"
                        }
                    ],
                    xAxis: {
                        type: "time",
                        splitNumber: 40,
                        axisLabel:{
                            formatter:function(val){
                                var date= new Date(val);
                                var ym = [date.getFullYear(), date.getMonth()+1,date.getDate()-1];
                                self.showTime ="日期:"+ ym.join("-");
                                var texts=[date.getHours(),date.getMinutes()];
                                return texts.join(":");
                            }
                        },
                        splitLine: {
                                     show: true, 
                                     //  改变轴线颜色
                                     lineStyle: {
                                                type:'dashed',
                                      // 使用深浅的间隔色
                                        color: ['rgba(0,0,0,0.2)']
                                            },
                                },
                        min:new Date(self.grid.XstartTime),
                        max:new Date(self.grid.XendTime),
                    },
                    yAxis: {
                        min:0,
                        max:29,
                        splitNumber : 29,
                        splitLine: {
                            show: true, 
                           //  改变轴线颜色
                                     lineStyle: {
                                                 type:'dashed',
                                      // 使用深浅的间隔色
                                        color: ['rgba(0,0,0,0.2)']
                                            },
                                },
                        data: self.grid.YAxisData,   
                        // axisLine: {
                        //     lineStyle: {
                        //     //color: "red"
                        //     color: "#000"
                        //     }
                        // }
                    },
                    tooltip: {
                        backgroundColor: "#F6F6F6",
                        borderWidth: 1,
                        borderColor: "rgba(0,0,0,.3)",
                        triggerOn: "click",
                        confine: true,
                        enterable: true,
                        transitionDuration: 0,
                        textStyle: {
                            color: "#333"
                        },
                        extraCssText: 'box-shadow: 0 0 5px 1px rgba(255, 255, 255, 0.3);',
                        padding: [5, 10],
                        position: function (pos, params, dom, rect, size) {
                            return [pos[0] + 10, pos[1]];
                        },
                        formatter:self.tooltipHander
                    },
                    series:[
                        {
                            name:'首次装夹',
                            type: 'custom',
                            encode: {
                                x: [1,2],
                                y: 0
                                },
                            itemStyle: {
                                normal: {
                                color:self.seriesColorHander,
                                opacity: 0.8,
                                    }
                                },  
                            renderItem:self.renderItem,
                            data:self.gantt.fristInstall
                        },
                        {
                            name:'次装夹',
                            type: 'custom',
                            encode: {
                                x: [1,2],
                                y: 0
                                },
                            itemStyle: {
                                normal: {
                                color:self.seriesColorHander,
                                opacity: 0.8,
                                    }
                                },  
                            renderItem:self.renderItem,
                            data:self.gantt.install
                        },
                        {
                            name:'程序运行',
                            type: 'custom',
                            encode: {
                                x: [1,2],
                                y: 0
                            },
                            itemStyle: {
                                normal: {
                                color:self.seriesColorHander,
                                opacity: 0.8,
                                }
                            },  
                            renderItem:self.renderItem,
                            data:self.gantt.runTime
                        },
                        {
                            name:'首检',
                            type: 'custom',
                            encode: {
                                x: [1,2],
                                y: 0
                            },
                            itemStyle: {
                                normal: {
                                color:self.seriesColorHander,
                                opacity: 0.8,
                                }
                            },  
                            renderItem:self.renderItem,
                            data:self.gantt.fristCheck
                        },
                    ]
                };
            self.option = option;
         return option;    
        },
        //点击lenged图标时触发
        legendSelect(){

        },
        //甘特图series处理函数
        seriesColorHander(params){
            let self = this;
            try {
                let key = params.value[12];
                let operator = params.value[13];
                let realoperator = params.value[14];
                    if(self.isContain(key)){
                        return '#E062AE';
                    }else{
                        if((operator !=null || realoperator!=null)&&params.value[11] !=1 && params.value[11] !=2){
                             return '#5c7a29';
                        }else
                        if(params.value[11]==2){
                            return "#ed1941";
                        }else if(params.value[11] ==1 ){
                            return "#45b97c";
                        } 
                        return "#ffc20e";
                    }
            } catch (error) {
                
            }
        },
        //判断参数是否在数组内部
        isContain(val){
            let self =  this;
            if(self.selectSperatorArray.indexOf(val)>-1){
                return true;
            }else{
                return false;
            }
        },
        //删除所传参数对应的值
        removeContain(val){
            let self =  this;
            self.selectSperatorArray.remove(val);   
        },
        //甘特图表格处理函数
        tooltipHander(params){
            let self = this;
                self.isInsertOrderBottom = true;
                self.closeIntervalTime();       //停止定时任务
                self.setInsertOrder(params);    //设置插单信息
                // console.log(JSON.stringify(params))
                // var res='<a href="javascript:void(0);" onclick="openWorkingCharts(\'' +1+'\')">查看详情</a><br/>' +'';
                // if(window.isCtrl){
                //     console.log("按住了ctrl");
                //     //改变所点击的数据块颜色
                // }else{
                //     //恢复所点击的数据块颜色
                //     console.log("放开了ctrl");
                // }
                    var state = params.value[11]==2?"未保存":params.value[11]==1?"已同步":"已保存";
                    window.params = params;
                    self.dialog.detailSearchCondtion.tId = params.value[7];
                    self.dialog.detailSearchCondtion.totalId = params.value[8];
                    var res='<a href="javascript:void(0);"  onclick="openOperator()">操作人</a>';
                    var operation ='&nbsp;&nbsp;<a href="javascript:void(0);"  onclick="openResponse()">实操人</a>';
                    var detail ='&nbsp;&nbsp;<a href="javascript:void(0);"  onclick="openDeatil()">查看详情</a></br>';
                    var operator = params.value[13]==null?"未设置":params.value[13];
                    var realoperator = params.value[14]==null?"未设置":params.value[14];
                    var planResultId = params.value[12];    //id
                        self.operator.planResultId = planResultId;
                        res = res+operation+detail;
                    var date0 = new Date(params.value[1]);
                        date0 = date0.getFullYear() + "-" + (date0.getMonth() + 1)+"-"+date0.getDate()+" "+date0.getHours()+":"+date0.getMinutes()+":"+date0.getSeconds();
                    var date1 = new Date(params.value[2]);
                        date1 = date1.getFullYear() + "-" + (date1.getMonth() + 1)+"-"+date1.getDate()+" "+date1.getHours()+":"+date1.getMinutes()+":"+date1.getSeconds();
                        res = res+"设备编号："+ params.name + "</br>"+
                                          "生产令号："+params.value[3]+"</br>"+
                                          "图纸号："+params.value[4]+"</br>"+
                                          "加工面: "+params.value[5]+"</br>"+
                                          "工序："+params.seriesName+"</br>"+
                                          "操作人员："+operator+"</br>"+
                                          "实操人员："+realoperator+"</br>"+
                                        //   "备注："+params.seriesName+"</br>"+
                                         "开始时间："+date0+"</br>"+
                                         "结束时间："+date1+"</br>"+
                                         "状态："+state+"</br>"+
                                         "<hr/>";
                    return res;
        },
        //渲染风格
        renderItem(params, api) {
            let categoryIndex = api.value(0);
            let start = api.coord([api.value(1), categoryIndex]);
            let end = api.coord([api.value(2), categoryIndex]);
            let height = api.size([0, 1])[1] * 1;

            let rectShape = echarts.graphic.clipRectByRect({
                x: start[0],
                y: start[1] - height / 2,
                width: end[0] - start[0],
                height: height
            }, {
                x: params.coordSys.x,
                y: params.coordSys.y,
                width: params.coordSys.width,
                height: params.coordSys.height
            });

            return rectShape && {
                type: 'rect',
                shape: rectShape,
                style: api.style()
            };
        },
        //进行后台参数设备最近完成任务时间赋值
        setInitMacTime(macAraay){
            let self = this;
            if(!self.isPlan){
                for (let index = 0; index < macAraay.length; index++) {
                    const element = macAraay[index];
                    switch (element.mac+'') {
                        case '1':self.table.machine.mac1.initTime=new Date(element.maxEndTime);  break;
                        case '2':self.table.machine.mac2.initTime=new Date(element.maxEndTime);  break;
                        case '3':self.table.machine.mac3.initTime=new Date(element.maxEndTime);  break;
                        case '4':self.table.machine.mac4.initTime=new Date(element.maxEndTime);  break;
                        case '5':self.table.machine.mac5.initTime=new Date(element.maxEndTime);  break;
                        case '6':self.table.machine.mac6.initTime=new Date(element.maxEndTime);  break;
                        case '7':self.table.machine.mac7.initTime=new Date(element.maxEndTime);  break;
                        case '8':self.table.machine.mac8.initTime=new Date(element.maxEndTime);  break;
                        case '9':self.table.machine.mac9.initTime=new Date(element.maxEndTime);  break;
                        case '10':self.table.machine.mac10.initTime=new Date(element.maxEndTime);  break;
                        case '11':self.table.machine.mac11.initTime=new Date(element.maxEndTime);  break;
                        case '12':self.table.machine.mac12.initTime=new Date(element.maxEndTime);  break;
                        case '13':self.table.machine.mac13.initTime=new Date(element.maxEndTime);  break;
                        case '14':self.table.machine.mac14.initTime=new Date(element.maxEndTime);  break;
                        case '15':self.table.machine.mac15.initTime=new Date(element.maxEndTime);  break;
                        case '16':self.table.machine.mac16.initTime=new Date(element.maxEndTime);  break;
                        case '17':self.table.machine.mac17.initTime=new Date(element.maxEndTime);  break;
                        case '18':self.table.machine.mac18.initTime=new Date(element.maxEndTime);  break;
                        case '19':self.table.machine.mac19.initTime=new Date(element.maxEndTime);  break;
                        case '20':self.table.machine.mac20.initTime=new Date(element.maxEndTime);  break;
                        case '21':self.table.machine.mac21.initTime=new Date(element.maxEndTime);  break;
                        case '22':self.table.machine.mac22.initTime=new Date(element.maxEndTime);  break;
                        case '23':self.table.machine.mac23.initTime=new Date(element.maxEndTime);  break;                
                        case '24':self.table.machine.mac24.initTime=new Date(element.maxEndTime);  break;                
                        case '25':self.table.machine.mac25.initTime=new Date(element.maxEndTime);  break;                
                        case '26':self.table.machine.mac26.initTime=new Date(element.maxEndTime);  break;                
                        case '27':self.table.machine.mac27.initTime=new Date(element.maxEndTime);  break;                
                        case '28':self.table.machine.mac28.initTime=new Date(element.maxEndTime);  break;                
                        case '29':self.table.machine.mac29.initTime=new Date(element.maxEndTime);  break;                
                        case '30':self.table.machine.mac30.initTime=new Date(element.maxEndTime);  break;                
                        case '31':self.table.machine.mac31.initTime=new Date(element.maxEndTime);  break;                
                        case '32':self.table.machine.mac32.initTime=new Date(element.maxEndTime);  break;                
                        case '33':self.table.machine.mac33.initTime=new Date(element.maxEndTime);  break;                
                        case '34':self.table.machine.mac34.initTime=new Date(element.maxEndTime);  break;                
                        case '35':self.table.machine.mac35.initTime=new Date(element.maxEndTime);  break;                
                        case '36':self.table.machine.mac36.initTime=new Date(element.maxEndTime);  break;                
                        case '37':self.table.machine.mac37.initTime=new Date(element.maxEndTime);  break;                
                        case '38':self.table.machine.mac38.initTime=new Date(element.maxEndTime);  break;                
                        case '39':self.table.machine.mac39.initTime=new Date(element.maxEndTime);  break;                
                        case '40':self.table.machine.mac40.initTime=new Date(element.maxEndTime);  break;                
                        default:
                            break;
                    }
                }
            }
        },
        //保存确定框
        savePlan(){
            let self = this;
            self.isPlan = false;
            // if(self.isPlanTimeOut){
            //       self.$message({
            //             message: '有超时计划，无法保存！！',
            //             type: 'success'
            //         });
            //     return;
            // }
            this.$confirm('请确定是否保存!!!', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(()=>{  
            self.isloading = true; 
            let params={
                planResults:{
                        fristInstall:self.save.fristInstall,
                        install:self.save.install,
                        runTime:self.save.runTime,
                        fristCheck:self.save.fristCheck
                }
            };
            planApi.insertPlanTaskGanttMapData(params).then(res=>{
                self.restGanttMap();            //保存成功后刷新甘特图
                self.restfuSpetTable();         //保存成功后刷新加工面展示框
                self.$message({
                        message: '数据保存成功！',
                        type: 'success'
                    });
            });
                 
            }).catch(()=>{
               console.log("取消操作！！！");
            });
        },
        //插单保存
        saveInsertOrder(){
            let self = this;
            self.isPlan = false;
            // if(self.isPlanTimeOut){
            //       self.$message({
            //             message: '有超时计划，无法保存！！',
            //             type: 'success'
            //         });
            //     return;
            // }

            this.$confirm('请确定是否保存!!!', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(()=>{  
            //self.isloading = true; 
            let params={
                planResults:{
                        fristInstall:self.save.fristInstall,
                        install:self.save.install,
                        runTime:self.save.runTime,
                        fristCheck:self.save.fristCheck
                }
            };
            //planResultId,Integer mac,String newTime

            let byBottomInsertOrderParam ={
                        planResultId:self.operator.planResultId,
                        mac:self.insertOrder.macId,
                        newTime:self.timestampToTime(self.insertOrder.showTime,'yyyy-mm-dd hh:mm:ss'),
                 };
            if(self.isInsertOrderBottom){
                planApi.insertOrderDataByConditionList(byBottomInsertOrderParam).then(res=>{
                    self.restGanttMap();            //保存成功后刷新甘特图
                    self.restfuSpetTable();         //保存成功后刷新加工面展示框
                    self.$message({
                            message: '数据保存成功！',
                            type: 'success'
                        });
                    });           

            }else{
                planApi.saveInsertOrderData(params).then(res=>{
                    self.restGanttMap();            //保存成功后刷新甘特图
                    self.restfuSpetTable();         //保存成功后刷新加工面展示框
                    self.$message({
                            message: '数据保存成功！',
                            type: 'success'
                        });
                    });           

            }
            }).catch((e)=>{
               console.log("取消操作！！！"+e);
            });
        },
        //刷新表格单
        restfuSpetTable(){
            let self = this;
               planApi.planTaskDetailList(self.table.currentPlanFousRow.id,self.table.currentPlanFousRow.totalId).then(res=>{
                self.table.data.septTableData = res.content;
            });
        },
        //定时任务开启
        openIntervalTime(){
            let self = this;
            timer = window.setInterval(self.sendWebSocket,5000);
            self.sychVal = true;
            console.log("开启定时刷新任务....");


        },
        //定时任务关闭
        closeIntervalTime(){
            let self = this;
            console.log("取消定时任务....");
            window.clearInterval(timer);
            self.sychVal = false;
        },
        clostWebSocket(){
            let self = this;
            this.websocket.close();
        },
        sendWebSocket(){
            let self = this;
            let date = self.timestampToTime(self.search.date,'yyyy-mm-dd') ;
            console.log("定时刷新任务==》date:"+date);
            self.websocket.send(date);
        },
        initWebSocket(){ //初始化weosocket 
                //  process.env.WS_API + 
                let self = this;
                const wsuri = this.apiConfig.wsHost;//ws地址
                    if("WebSocket"in window){
                            self.websocket = new WebSocket(wsuri);
                        }else if("MozWebSocket" in window){
                            self.websocket = new MozWebSocket(wsuri);
                        }else{
                            alert("WebSocket is not supported by this browser.");
                            return;
                        }
                    

                    self.websocket.onopen = self.websocketonopen;

                    self.websocket.onerror = self.websocketonerror;

                    self.websocket.onmessage = self.websocketonmessage; 
                    self.websocket.onclose = self.websocketclose;
        },
        websocketonopen() {
            let self = this;
            self.openIntervalTime();
            console.log("WebSocket连接成功");
        },
        websocketonerror(e) { //错误
            console.log("WebSocket连接发生错误");
        },
        websocketonmessage(res){ //数据接收 
                let self = this;
                //注意：长连接我们是后台直接1秒推送一条数据， 
                //但是点击某个列表时，会发送给后台一个标识，后台根据此标识返回相对应的数据，
                //这个时候数据就只能从一个出口出，所以让后台加了一个键，例如键为1时，是每隔1秒推送的数据，为2时是发送标识后再推送的数据，以作区分
                // let content =eval('('+res+')');
                //console.log(res.data);
                let resJsonObject = JSON.parse(res.data);
                let resJsonObjectContent = JSON.parse(resJsonObject.content);
                //1进行查询数据的备份存储
                self.original.fristInstall = resJsonObjectContent.planResults.fristInstall;
                self.original.install =resJsonObjectContent.planResults.install;
                self.original.runTime =resJsonObjectContent.planResults.runTime;
                self.original.fristCheck =resJsonObjectContent.planResults.fristCheck;
                self.original.macEndTime =resJsonObjectContent.planResults.macEndTime;
                //2进行甘特图展示数据查看
                self.gantt.fristInstall =resJsonObjectContent.planResults.fristInstall;
                self.gantt.install =resJsonObjectContent.planResults.install;
                self.gantt.runTime =resJsonObjectContent.planResults.runTime;
                self.gantt.fristCheck =resJsonObjectContent.planResults.fristCheck;
                self.gantt.macEndTime = resJsonObjectContent.planResults.macEndTime;
                //进行上次保存的数据存档
                self.gantt.fristInstall =  self.gantt.fristInstall.concat(self.save.fristInstall);
                self.gantt.install =  self.gantt.install.concat(self.save.install);
                self.gantt.runTime =  self.gantt.runTime.concat(self.save.runTime);
                self.gantt.fristCheck =  self.gantt.fristCheck.concat(self.save.fristCheck);
                self.isloading = false;
                self.initGanttMap();
                self.setInitMacTime(self.gantt.macEndTime);
        }, 
        websocketsend(agentData){//数据发送 
            // let self = this;
            // let date = self.timestampToTime(self.search.date,'yyyy-mm-dd') ;
            // self.websocket.send(date);
        }, 
        websocketclose(e){ //关闭 
              let self = this;
              console.log("connection closed (" + e.code + ")"); 
              console.log("数据同步接口异常,请刷新页面重试链接......");

        },
        //检查保存操作人员是否为空
        checkParamsEmpty(){
            let self = this;
            if((self.operator.planResultId==null ||self.operator.planResultId==undefined || self.operator.planResultId=='')&&(self.selectSperatorArray==null ||self.selectSperatorArray==undefined||self.selectSperatorArray.length==0)){
                self.$message({
                    message: '请先选择操作工序!!!',
                    type: 'success'
                });
                return false;
            }else{
                return true;
            }
        },
    }
}
window.openDeatil = function (){
    window.self.dialogDetailVisible = true;
    window.self.getDetailInfo();
};
window.openResponse = function (){
    if(window.self.checkParamsEmpty()){
        window.self.dialogResponseVisible = true;
    }
    console.log(window.params);
   
};
window.openOperator = function (){
    if(window.self.checkParamsEmpty()){
        window.self.dialogOperatorVisible = true;
    }
    console.log(window.params);
   
};
window.isCtrl = false;
window.onkeydown = function(event){
    let e = event || window.event || arguments.callee.caller.arguments[0]; 
    if(e.ctrlKey){    
        window.isCtrl = true;
            }    
        };
window.onkeyup  = function(event){
    let e = event || window.event || arguments.callee.caller.arguments[0]; 
    if(!e.ctrlKey){    
        window.isCtrl = false;
        }
    };
//获取元素在数组的下标
Array.prototype.indexOf = function(val) {
	for (var i = 0; i < this.length; i++) {
		if (this[i] == val)	{ 
			return i;
		};
	}
	return -1; 
};

//根据数组的下标，删除该下标的元素
Array.prototype.remove = function(val) {
	var index = this.indexOf(val);
	if (index > -1) {
	this.splice(index, 1);
	}
};

//测试数据
var insertAttaList = ['abs','dsf','abc','sdf','fd'];
insertAttaList.remove('dsf');
console.log(insertAttaList);
</script>
<style >
.data_box {
    padding-bottom: 10px;
  }
.el-button {
    margin-left: 10px;
  }
.el-card__body {
    padding: 1px!important;
}
.el-popper[x-placement^="bottom"]{
    z-index: 9999!important;
}
.el-popper{
    z-index: 9999!important;
}
.el-message-box__wrapper{
    z-index: 9999!important;
}
.el-date-editor.el-input, .el-date-editor.el-input__inner{
    margin: 10px;
}
.red{
    color: red;
}
.black{
    color:black;
}
.el-form-item--small.el-form-item {
    margin-bottom: 0px;
    /* padding: 0 0 0 0; */
    line-height: 3;
    height: 30px;
}
</style>